<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">I was writing some object oriented code over the weekend and upon returning to my Erlang coding, I accidentally discovered this rather odd construction:</span><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"> ....</div><div style="font-family:arial,sans-serif;font-size:13px"> Dict = lists:foldr(...), % dict construction</div><div style="font-family:arial,sans-serif;font-size:13px">
lists:map(fun(...) -> ... end, Dict:to_list() <<-- WHUT?!</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Testing it, it seems that the runtime has the following convention;</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">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). </div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">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 Erlang?</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">An example:<br></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
<div>Erlang R16B01 (erts-5.10.2) [source] [64-bit halfword] [smp:32:32] [async-threads:10] [kernel-poll:false] [systemtap]</div><div><br></div><div>Eshell V5.10.2 (abort with ^G)</div><div>1> T = {erlang, foo, bar, baz}.</div>
<div>{erlang,foo,bar,baz}</div><div>2> T:tuple_to_list().</div><div>[erlang,foo,bar,baz]</div><div>3> </div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
BRs,</div><div style="font-family:arial,sans-serif;font-size:13px">Raphael K</div></div>