[erlang-questions] some language changes

Robert Virding robert.virding@REDACTED
Mon Jun 4 23:28:02 CEST 2007


Corrado Santoro wrote:
> my two cents....
> 
>> The only clean way to do that would be to introduce proper variable 
>> scoping, but that is a big change, both syntax and semantics.
> ...uhmmmm.... but how can you do "A = A + 1" using variable scoping?? 
> Maybe introducing a syntax which is more and more hard than "A1 = A + 1"?
> 
> IMHO, I don't think that it could be the case...

If you added the scoping of variables so that variables occurring in 
patterns are always new variables, removed exporting variables and only 
returned values, and added a let construct:

let {A,B,C} = foo(A, B, C) ->
     ...
end

where A,B,C occurring in the body of the let refer to A,B,C in the pattern,

then you could reuse variable names. But there would be no gain as such 
in the manner of the original suggestion:

let A = A + 1 ->
     ...
end

Actually this change is perfectly feasible to do as it does not affect 
any fundamental semantics of Erlang. In fact the compiler internally 
does just this.

Robert

P.S. I don't suggest let ... in ... end as 'in' is used in may places 
and making it a reserved word would be impossible now.



More information about the erlang-questions mailing list