Hi --

On Wed, 8 Oct 2008, Jim Weirich wrote:

>
> On Oct 7, 2008, at 10:23 AM, _why wrote:
>
>>> The second conversation is about temporarily adding methods to the current
>>> object in order to get DSL-like capabilities.  This was thread was
>>> introduced by the suggestion of using the mixin/unmixin techniques.
>> 
>> I really think this is a good idea for a `with` method, though.
>> Rather than altering `self`, we could temporarily re-route methods.
>> I'm saying that we take mixins a step further: beyond modules and on
>> to objects, any object at all.
>
> But if I understand the implementation, you are not intercepting the 
> messages.  They still go to the original object.  All you've done is redefine 
> the messages.  How do you plan to redirect them to the object given in the 
> 'with' statement?
>
> BTW, I totally agree with taking mixins to the object level.  If that were 
> done, a lot of my concern over thread-safety would be alleviated (since you 
> are only modifying the methods for a single object rather than the methods 
> for *all* the objects of that class.

Isn't that what extend does? (Not that it's thread-specific, of
course, if the object is visible in multiple threads.)

I have to say I've always been intrigued by how little use the
import-module and other such libraries have gotten. (I don't mean Ruby
Behaviors, which in its existing form was never destined to be widely
used.) There's always been interest in having block-scoped module
inclusion and such, but I can't remember any discussion of anyone
actually using import-module (which doesn't mean no one has, of
course).

I'm just musing out loud; that last paragraph isn't specifically an
answer to your post.


David

-- 
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!