Charles Oliver Nutter wrote:
> require 'namespaces'
> namespace :foo, %{
>    class Array
>      def each
>        # do something new
>      end
>    end
>    p Array.new.collect
> }
> 
> The default implementation of Enumerable#collect calls each. Would you
> expect collect to see the original each method or the one you've
> provided in the namespace?

I'd expect Enumerable to use the Array#each as defined in that 
namespace, the same way it would in current ruby if I changed 
Array#each. But I think I begin to see a thought mistake. I guess I have 
to think about it a bit :-/

> See the above example; if you only want namespaces so that within a
> given block of code method calls to where you want them to, that's
> simpler to implement. But it breaks some amount of consistency you might
> expect. It seems like if selector namespacing is useful (which I'm
> unsure of) it would only be generally useful if it could also affect
> calls further down the chain. Maybe I'm wrong?

I think I'd have to actually play with it and see problems. Maybe you're 
right :)
But from what I think at the moment, consistency expectations would be a 
problem with any namespace implementation. But maybe I'm wrong?

Regards
Stefan
-- 
Posted via http://www.ruby-forum.com/.