[erlang-questions] noob namespace question
Wed Dec 12 19:38:56 CET 2012
On Wed, Dec 12, 2012 at 01:30:03PM -0500, Thomas Allen wrote:
> 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:
Note that there are ways to make atoms as functions usable. You will
have to export functions you are calling this way, even if they are
internal to your module:
test1(a) + test2(b).
test1(Fn) -> ?MODULE:Fn().
test2(Fn) -> apply(?MODULE, Fn, ).
a() -> 1.
b() -> 2.
You will see that:
These are two ways to call a function with nothing but an atom.
More information about the erlang-questions