On 12.04.2008 20:40, Chris Shea wrote:
> On Apr 12, 10:49 am, Roger Pack <rogerpack2... / gmail.com> wrote:
>> I wish you could have distinguishable separatable name-spaces, something
>> along the lines of
>>
>> class Abc
>> end
>> namespace one
>>  class Abc
>>    def func1
>>    end
>>  end
>> end
>>
>> namespace two
>>  # class Abc will NOT have func1, right here
>> end
>>
>> ok maybe it wouldn't be all that widespread used, but somewhat useful
>> for keeping code nice and separate.
>> Thanks for reading :)
>> -R
> 
> Can you show a use case where using modules as namespaces isn't enough?

That was my first reaction as well.  But now I suspect that Roger wanted 
::Abc and ::one::Abc to be the _same class_ but method func1 should only 
be visible in namespace one.  With modules there were two distinct 
classes that would not have anything in common.  In this particular case 
the behavior could be emulated with inheritance:

class Abc
end

module one
   class Abc < ::Abc
     def func1
     end
   end
end

but it would not be the same and not work in all cases where the wished 
for feature would work.  I believe the concept has been discussed under 
the term "selector namespaces" numerous times here.  I cannot remember 
the current status of this feature though. :-)

Personally I am not yet convinced that the feature would be so great. 
My doubts are fed by the increased complexity of the language 
implementation as well as complexity of the code that uses this feature. 
  For example, what happens in this case:

class Foo; end

module Bar
   class Foo
     def bar_meth; end
   end

   class Inherited < Foo
     def test
       bar_meth # ok here because in Bar
     end
   end
end

class WhatNow < ::Bar::Inherited
   def test2
      test # error or not?
      bar_meth # error or not?
   end
end

Kind regards

	robert