[erlang-questions] reference a fun from its atom name

Roberto Ostinelli <>
Mon Jun 18 17:04:48 CEST 2012


On Monday, June 18, 2012, Samuel wrote:

> > Thank you all, I ended up using this one.
> >
> >> F = hello_test_, Fun = fun ?MODULE:F/0.
>
> Note that this is not exactly what you were trying to do. I guess you
> were trying to create a fun to call a local (possibly unexported
> function).


no, this is exactly what I wanted to do. I have a function name as an atom
in a variable, and I needed a Fun reference out of it.

Your problem was that instead of a fun you defined an atom:
>
> 2> FunName = 'hello_test_/0'.
> 'hello_test_/0'
>
> Anything enclosed in '' is an atom. What you were trying to do is probably
>
> 2> FunName = fun hello_test_/0.


no, believe it or not but I actually may know the difference between an
atom and a function. no matter how incredible this may sound.

:)

...r.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120618/693b7f42/attachment.html>


More information about the erlang-questions mailing list