On Feb 19, 2009, at 8:15 AM, Charles Oliver Nutter wrote:

> Charles Oliver Nutter wrote:
>> Caveats:
>> * HACKHACKHACK
>> * Only works for single-arg "call" in this case, but easy to  
>> generalize to all other calls
>> * The namespace never gets turned off in this example. It wouldn't  
>> be hard to add with parser help, but there's no trigger I can use  
>> in this simple version.
>> * Interpreter-only. Compilation would be a bit trickier, but not  
>> much.
>
> Another important one:
>
> * This version searches the namespace for the method  
> *unconditionally*. It would probably be desirable to identify  
> whether it applies to the receiver or not:
>
> use String => Merb::String
>
> And then the namespace association only applies when the receiver  
> is_a? String.
>
> - Charlie
>


That sounds a lot like the Objective-C method poseAs, discarding some  
of it's limitations.

But what is the scope of use? AFAIK, there is no construct in Ruby  
that has a file-only scope (except the ones that need to be closed  
because of syntactical reasons). Granted, those are details.

But what about this example in Yehudas gist:

===
# require "my_app3", :use => Merb::String

"hello_goodbye".camel_case #=> "HelloGoodbye"
"hello_goodbye".camel_case(true) #=> ArgumentError
===

Making it externally controllable which class a file uses is at least  
discussable. I don't like it, especially because it is not really  
fitting in Rubys way of not seeing files as program units. Also, only  
one parametrization can be in place at once, which smells like a  
source of conflicts.

Regards,
Florian Gilcher

--
Florian Gilcher

smtp:   flo / andersground.net
jabber: Skade / jabber.ccc.de
gpg:    533148E2