Gus Wirth wrote:

Problem one: The examples immediately start to use function overloading even when the functions are not related except for the fact they happen to be in the same module. To me this is the epitome of stupid instruction as well as bad programming. Not only does it introduce a concept before its time but it serves to confuse and obscure the operation of the program.

I presume you are referring to:

-module(tut2).
-export([convert/2]).

convert(M, inch) ->
    M / 2.54;

convert(N, centimeter) ->
    N * 2.54.


I'll somewhat defend this one (but not the next one, see below). This appears as function overloading to those coming from a different language. I will agree, though, that this should probably be flagged out since it caused confusion.


This is really rule matching and you *MUST* get this concept immediately or you cannot proceed with the language.

Those are *not* different functions. They are two clauses of the *same* function. Note that the first ends with a ";" and the second ends with a "."


I'm not sure how you make this better. The next step is tuple matching followed by recursive matching. The progression is fairly logical.

This didn't really cause me any confusion. However, I don't know why. Presumably because I saw the previous example with recursion clauses so I never really thought about this as overloading. I figure that I anticipated where they were going with this since Erlang is a functional language.

Problem two: Using the same word for functions and atoms. In section three, you can see they use the same words for the functions and the atoms despite the fact they are used for different things and are commingled. This causes unnecessary confusion and again is bad form.

Yeah, I can see your point, now that I went and looked at it again.

Somehow, I didn't really notice the issue with the "ping" atom and the "ping" function. I'm used to using the same names for signals in Verilog/VHDL as they pass up the chain through different forms so I didn't really notice as it changed from atoms to functions.

I tend to segregate those in my code. I use StudlyCaps for variables, studlyCaps for atoms, and under_scores for functions.

-a

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to