[erlang-questions] noob namespace question

Thomas Allen thomas@REDACTED
Wed Dec 12 19:30:03 CET 2012


On Wed, Dec 12, 2012 at 11:44:43PM +0530, 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?

This is not valid, and you will get a "bad function" error if you try to
pass your function this way. You must create a "fun" like so:

  h(fun foo/0)

Similarly, you could pass an anonymous fun (like fun(X) -> X end), or
a module-function combination (like fun lists:reverse/1).

Thomas Allen



More information about the erlang-questions mailing list