[erlang-questions] nested variable assignment : bug or the expected behaviour ?

James Churchman <>
Tue Jun 26 00:55:44 CEST 2012


Small syntax related thing

If i have a function like :

f()->[J=100,J].

Or put in the shell:
{J=200,J}.

Or

erlang:'+'(J=10,J).

Or any other combination of where i try to set a variable nested
inside somewhere else, it will say "variable 'J' is unbound" .. is
this the expected behaviour ?

( if i do bind the value before tho it will it will fail with no match
of right hand side value XX which is to be expected )

I only ask as i want to type :

[
{1, N1=now() ,0 },
{2, N2=now() ,N1 },
{3, N3=now() ,N2 }
]

I realise I could generate all the NXX now's before, or write a
function to put each now result in the flowing tuple but its just for
some simple test code and the behaviour was not as i wanted :-)


James



More information about the erlang-questions mailing list