[erlang-questions] noob namespace question
Thu Dec 13 01:33:59 CET 2012
On 13/12/2012, at 6:58 AM, Rustom Mody wrote:
> In Erlang variables start with a capital letter, atoms start with a lowercase letter.
> Functions also start with lowercase.
> How does Erlang distinguish atoms and functions? Especially in the context of higher order functions.?
atom in 'fun <atom>/<arity>' => function reference
atom followed by left parenthesis => function reference
atom anywhere else => just an atom
Similar rule for variables. f(G(h,I))
f( static call to f/1
G( dynamic call to whatever G is bound to (which must be arity 2)
h plain data, used not called
I value of I, used not called.
If you want to pass the name of a function as a parameter to
a higher-order function, you have to use 'fun <atom>/<arity>',
not _entirely_ unlike Lisp's #'<atom>.
More information about the erlang-questions