[erlang-questions] Invoking function as record-member

Jeroen Koops koops.j@REDACTED
Wed Nov 5 22:03:08 CET 2008


I have a record with a member to which I assign a function:

$ cat test.hrl
-record(test, { my_fun }).

and, from the Erlang shell:

18> rr("test.hrl").
19> X=#test{my_fun = fun(X) -> X*2 end}.
#test{my_fun = #Fun<erl_eval.6.49591080>}

When I try to invoke the function, the shell complains with a syntax error:

20> X#test.my_fun(1).
** 1: syntax error before: '(' **

Of course, it does work when first assigning the record-member to a

21> Y=X#test.my_fun.
22> Y(1).

Is there some syntactical subtlety I'm missing out on, or is this something
I should just not want?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081105/a77c4dda/attachment.htm>

More information about the erlang-questions mailing list