[erlang-questions] Invoking function as record-member
Jeroen Koops
koops.j@REDACTED
Wed Nov 5 22:03:08 CET 2008
Hello,
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").
[test]
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
variable:
21> Y=X#test.my_fun.
#Fun<erl_eval.6.49591080>
22> Y(1).
2
Is there some syntactical subtlety I'm missing out on, or is this something
I should just not want?
Thanks,
Jeroen
-------------- 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