From: Mike Gold Date: 2008-10-01T03:40:08+09:00 Subject: Re: ruby1.9 block scope Yukihiro Matsumoto wrote: > > Yes, but > > * Class.new and define_method is a rather rare examples, of which > non-block counterpart introduce new scopes. But it's not a rare example for me. It's a great solution to an otherwise tangled problem. When I have more time I can post some code if my example is not convincing. The whole point is that I don't want to introduce a new scope. As I briefly mentioned, I am writing adapters which put a "new face" on the current binding so that other levels can understand it. By contrast, it would be convoluted to create all new scopes each with instance variables pointing back to the places I just came from. The code would be Java-like: reams of scaffolding which serve no end except to compensate for a missing language feature. > * In 1.9, you can have explicit block local variables if you expect > any confusion. I would use the block local syntax every time, because I would always expect confusion. The ruby "good feeling" would be gone, for me. Effectively it would be Lisp "let" constructs, which is fine I guess, but it's Lisp. I have always thought of ruby as a (non-defmacro) Lisp "optimized" to make programmers more happy. In this case I feel the proposed "optimization" goes too far, producing unexpected behavior like in the example I gave. But I realize POLS refers to your surprise, not my surprise. -- Posted via http://www.ruby-forum.com/.