Hi,
In message "Re: Lexical scope and closures"
on 03/02/13, "Hal E. Fulton" <hal9000 / hypermetrics.com> writes:
|What happens to the case where obj has a meth= method, and
|we put obj.meth between vertical bars?
This will cause warning first, then eventually become error in the far
future version. Block parameters will be more like method arguments.
|And how will I save the value of an iterated variable? Will I have
|to assign it to a var in the outer scope as soon as I enter the
|block?
You have to assign to a variable from a block parameter.
|> It will also break old code where it depends on a variable introduced in a
|> block being local, e.g.
|>
|> Thread.new {
|> i = 0
|> ... use i locally
|> }
|>
|> I don't remember seeing a warning for this situation being discussed, but
|it
|> would seem logical to do so.
|
|Hmm, even more confusing. But perhaps you could simply add
|your block-local variable(s) to the list: Thread.new {|i|...
Yes, it's possible, even now.
|It seems that Matz's INVIOLABLE rule is to keep Ruby
|declarationless. Every solution I saw (I think) that
|kept all functionality involved some kind of declaration
|mechanism.
Yes, for variable declarations. But I'm always open for new ideas.
matz.