[erlang-questions] What is this OOP-like construction doing in Erlang?

Raphael Korsoski psidrinal@REDACTED
Mon Nov 4 16:05:37 CET 2013

I was writing some object oriented code over the weekend and upon returning
to my Erlang coding, I accidentally discovered this rather odd construction:

    Dict = lists:foldr(...), % dict construction
    lists:map(fun(...) -> ... end, Dict:to_list()  <<-- WHUT?!

Testing it, it seems that the runtime has the following convention;

If T is a tuple, then the Mod:Fun(Args) construction T:Fun(Args) will in
fact be interpreted as element(1,T):Fun(Args, T).

I would expect something like that in an OO language; although the
convention in every language I have used is then to pass the 'self'
reference as the _first_ argument. What is this construction doing in

An example:

Erlang R16B01 (erts-5.10.2) [source] [64-bit halfword] [smp:32:32]
[async-threads:10] [kernel-poll:false] [systemtap]

Eshell V5.10.2  (abort with ^G)
1> T = {erlang, foo, bar, baz}.
2> T:tuple_to_list().

Raphael K
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131104/0548e20a/attachment.htm>

More information about the erlang-questions mailing list