[erlang-questions] case expression scope
Richard A. O'Keefe
ok@REDACTED
Wed Mar 5 04:00:36 CET 2014
On 5/03/2014, at 5:10 AM, Daniel Goertzen wrote:
> I've been reflecting on this some more, and have realized one of my biases on the subject comes from the way C/C++ manages scope: Anything within curly braces, whether it is a function, if, while, for, try, or catch, is a scope which encapsulates all declarations within. This uniform rule makes it easier to reason about code, and not having it in Erlang is, well, jarring to me.
This is rather confusingly worded. In Classic C and C89,
new scopes were introduced by '{...}' and only by '{...}.
There was a proposal years ago to add
begin
<body1>
within
<body2>
end
to Erlang with the idea that variable bindings introduced
in <body1> would be visible in <body2> but not outside,
while variable bindings in <body2> would be visible outside
as usual.
I don't know why that was rejected.
More information about the erlang-questions
mailing list