News for hackers. Stuff that matters.
Re:Ruby's not ready by tptacek on Monday April 07, 2008 @10:41PM (#157449)
Your "bug" is lexical scoping?
Re:Ruby's not ready by akkartik on Monday April 07, 2008 @10:55PM (#157461)
No, it's lack of consistent lexical scoping.

Either ruby blocks create a new scope or they do not. Which is it?

Re:Ruby's not ready by tptacek on Monday April 07, 2008 @10:58PM (#157466)
They create new scopes, and close over the their enclosing environment. In other words, it supports both block-local variables and closures.
Re:Ruby's not ready by akkartik on Monday April 07, 2008 @11:00PM (#157470)
I don't understand. You mean there's a good reason for it to overwrite variables in outer scopes if they exist?

Is there any way to specify if I want block-local or not?

The way python deals with scopes is to provide read access to outer scopes if there are no writes to a variable.

Re:Ruby's not ready by tptacek on Monday April 07, 2008 @11:02PM (#157475)
Of course there is: if you couldn't access variables in the enclosing scopes, blocks would be drastically less useful. Ruby uses anonymous functions where Python would use a loop construct.
Re:Ruby's not ready by akkartik on Monday April 07, 2008 @11:16PM (#157492)
[We took this conversation offline. it seems this is a known gotcha (e.g. http://www.osix.net/modules/article/?id=401), and may be changed in ruby 2.0 (http://groups.google.com/group/sbonrails/browse_thread/threa...). Thanks tptacek.]