From: "David A. Black" Date: 2008-10-07T22:42:34+09:00 Subject: [ruby-core:19162] Re: [Feature #615] "with" operator Hi -- On Tue, 7 Oct 2008, Gary Wright wrote: > > On Oct 7, 2008, at 6:06 AM, David A. Black wrote: >> It's not so much a scope thing as a 'self' thing. My understanding is >> that it would produce a context where this happens: >> >> m # sent to one object >> @v # instance variable of a different object > > It seemed to me that something different was being proposed. During > the execution of the block, the object associated with 'self' is > augmented with additional methods. When the block finishes the > additional methods are withdrawn. It isn't the message dispatch > mechanism that is changing but instead the included module list of > the object's singleton class is being temporarily modified. > > So in your example, 'm' and '@v' are still evaluated relative to > the same 'self'. OK, I probably got it wrong. It sounds somewhat similar to import-module[1], which lets you do block-wise module inclusion/extension. Ruby Behaviors[2] has the same principle, though it's more proof-of-concept. David [1] http://blade.nagaokaut.ac.jp/~sinara/ruby/import-module/import-module-0.82/ [2] http://raa.ruby-lang.org/project/ruby_behaviors/ -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!