[erlang-questions] why can't use anonymous function in escript scripts?

Bjorn Gustavsson <>
Wed Feb 4 10:59:38 CET 2009


On Tue, Feb 3, 2009 at 7:01 AM, Liu Yubao <> wrote:
> Hi,
>
> `escript a.erl` complains:
> escript: exception error: undefined function erl_eval:myfun/0

We will try to fix that in R13A.

Meanwhile, you can use the following simple workaround:

fun() -> myfun() end

> If uncomment the second line, the script works well. It's strange
> I can eval "fun io:format/2." in erl shell.
>

Yes, but that is a completely different thing. You cannot evaluate
"fun myfun/0" in the shell:

1> fun myfun/0.
** exception error: undefined function erl_eval:myfun/0

/Bjorn
-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list