[erlang-questions] noob namespace question

Richard O'Keefe <>
Thu Dec 13 01:37:59 CET 2012


On 13/12/2012, at 7:14 AM, Rustom Mody wrote:
> I dont understand. Let me try and be more explicit about my concern.
> 
> Let h be a higher-order function of one argument (h/1)
> 
> Now in the call h(foo)
> How does Erlang know whether foo is a function or an atom?

For one thing, function names in Erlang are *NOT* atoms.
They are *PAIRS* <atom>/<arity>.  So if you just see an
atom, it cannot possibly be a function (or the name of a
function) because there simply is not enough information
there.

Actually, I told a lie.  Function names are
module:name/arity triples.  If you are referring to a
function in the same module, you can omit the module:
prefix.

If you wanted to call h passing it a reference to a local
function named foo with 3 arguments, you would have to write
h(fun foo/3).

In Common Lisp,
	(h 'foo)		the atom FOO
	(h foo)			value of the variable FOO
	(h #'foo)		the function FOO




More information about the erlang-questions mailing list