Selector Namespaces

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Selector Namespaces

Jan Vrany
Hi there,

recently I've been discussing selector namespaces and the the end,
if found out that I really don't know what it is and what people
mean when they talk about "selector namespaces".

1) Is there any paper/documentation/any other text (beside
the "Bergel, Ducasse, Nierstrasz: Analysing Module Diversity" paper)
describing selector namespaces and how they behave?

2) Is there any system that implements selector namespaces
(beside Smalltalk/X :-) available so I can download it and
play with it? If so, can you provide a link (then google-fu
is apparently bad)

That's how I understand selector namespaces (and what I assume
people are talking about when they say "selector namespaces")

A method is identified but its selector and its (selector) namespace.
Multiple methods with same selector but in different namespace may
coexist in a single class. Any selector namespace may import other
namespaces. When a message is sent within a method in namespace (say A),
then the method is (i) looked up in that namespaces (A in this case)
and (ii) if not found there, then all imported namespaces are searched
and so on until the method is found or there is no namespace imported
(which means that the method is definitely not found).

Example (method namespace is denoted by a string before ::)

namespace Y imports X;
namespace Z imports X;

class C {
   X::foo()  { print "X::foo" }
   Y::foo()  { print "Y::foo" }
   Z::foo()  { print "Z::foo" }
 
   X::bar()  { self.foo() }
   Y::bar()  { self.foo() }

   Y::baz()  { self.bar() }
   Z::baz()  { self.bar() }
}

Now, if Y::baz() is invoked, then "Y::foo()" is printed, because
bar() sent from namespace Y invokes Y::bar() which in turn invokes
Y::foo().
If Z::baz() is invoked, then "X::foo" is printed, because the
is no Z::bar(), so X is searched for bar() (because Z imports X)
X::bar() is executed which in turn executes X::foo().

3) Is behavior/mechanism outlined above what people call
   "selector namespaces"? If not, what is the behavior they talk about?

If it is, then (if not, following questions does not make sense):

4) What happens if namespace Z imports both, X __and__ Y?

5) There are people out there saying "selector namespaces are cool
because its implementation does not require changes to the VM.
All you need is to change the compiler to prefix selectors with
namespace..." (just like I did in my example). Then, how the namespace
imports are/can be implemented?

Hopefully I don't sound too foolish :-)

Cheers, Jan

Reply | Threaded
Open this post in threaded view
|

Re: Selector Namespaces

Alexandre Bergel-5
Hi Jan!

> recently I've been discussing selector namespaces and the the end,
> if found out that I really don't know what it is and what people
> mean when they talk about "selector namespaces".
>
> 1) Is there any paper/documentation/any other text (beside
> the "Bergel, Ducasse, Nierstrasz: Analysing Module Diversity" paper)
> describing selector namespaces and how they behave?

Not that I am aware of.

> 2) Is there any system that implements selector namespaces
> (beside Smalltalk/X :-) available so I can download it and
> play with it? If so, can you provide a link (then google-fu
> is apparently bad)

ModularSmalltalk had selector namespaces. S# as well. Not the code is not available. I've heard that the author did not have the code as well.

> A method is identified but its selector and its (selector) namespace.
> Multiple methods with same selector but in different namespace may
> coexist in a single class. Any selector namespace may import other
> namespaces. When a message is sent within a method in namespace (say A),
> then the method is (i) looked up in that namespaces (A in this case)
> and (ii) if not found there, then all imported namespaces are searched
> and so on until the method is found or there is no namespace imported
> (which means that the method is definitely not found).
>
> Example (method namespace is denoted by a string before ::)
>
> namespace Y imports X;
> namespace Z imports X;
>
> class C {
>   X::foo()  { print "X::foo" }
>   Y::foo()  { print "Y::foo" }
>   Z::foo()  { print "Z::foo" }
>
>   X::bar()  { self.foo() }
>   Y::bar()  { self.foo() }
>
>   Y::baz()  { self.bar() }
>   Z::baz()  { self.bar() }
> }
>
> Now, if Y::baz() is invoked, then "Y::foo()" is printed, because
> bar() sent from namespace Y invokes Y::bar() which in turn invokes
> Y::foo().
> If Z::baz() is invoked, then "X::foo" is printed, because the
> is no Z::bar(), so X is searched for bar() (because Z imports X)
> X::bar() is executed which in turn executes X::foo().

Yes

> 3) Is behavior/mechanism outlined above what people call
>   "selector namespaces"? If not, what is the behavior they talk about?
>
> If it is, then (if not, following questions does not make sense):

It is.

> 4) What happens if namespace Z imports both, X __and__ Y?

You are here assuming that you can have multiple import of namespaces. I am not sure what happened with ModularSmalltalk, and S# always missed essential documentation to accurately answer this question.

You have free room here!

> 5) There are people out there saying "selector namespaces are cool
> because its implementation does not require changes to the VM.
> All you need is to change the compiler to prefix selectors with
> namespace..." (just like I did in my example). Then, how the namespace
> imports are/can be implemented?

I know you said that :-)
Another implementation is you have an extra lookup (--> = lookup):
#bar --> #Y::bar --> compiled method

> Hopefully I don't sound too foolish :-)


It does not. This is an interesting topic

Cheers,
Alexandre

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.





Reply | Threaded
Open this post in threaded view
|

Re: Selector Namespaces

Jan Vrany
Hi,

thanks!

>
> > 2) Is there any system that implements selector namespaces
> > (beside Smalltalk/X :-) available so I can download it and
> > play with it? If so, can you provide a link (then google-fu
> > is apparently bad)
>
> ModularSmalltalk had selector namespaces. S# as well. Not the code is not available. I've heard that the author did not have the code as well.

Yes, I know these two but no one is available, not even without its
source code. Pity.

> > 4) What happens if namespace Z imports both, X __and__ Y?
>
> You are here assuming that you can have multiple import of namespaces. I am not sure what happened with ModularSmalltalk, and S# always missed essential documentation to accurately answer this question.
>
> You have free room here!
In this case, my implementation sends #ambiguousMessageSend: aMessage to
the original receiver, which in turn raises AmbiguousMessageSendError,
much like DNU mechanism.

>
> > 5) There are people out there saying "selector namespaces are cool
> > because its implementation does not require changes to the VM.
> > All you need is to change the compiler to prefix selectors with
> > namespace..." (just like I did in my example). Then, how the namespace
> > imports are/can be implemented?
>
> I know you said that :-)
> Another implementation is you have an extra lookup (--> = lookup):
> #bar --> #Y::bar --> compiled method
...which is another form of VM tweaking. For sake of completeness:
one may instrument the code using call-site simulator objects. Not
a way go in a long term, I think :-)

What interests me is how use them in real life. How to partition the
code among the namespaces, how to manage imports, is a really good idea
to have "nothing or everything" import scheme, thinks like that...

Anyway, thanks!

Jan


Reply | Threaded
Open this post in threaded view
|

Re: Selector Namespaces

Alexandre Bergel-5
Keep us informed if you made some progress on that front.
Indeed, how using SelectorNamespace is a topic that no many have worked on.

Cheers,
Alexandre


On 22 Sep 2011, at 14:05, Jan Vrany wrote:

> Hi,
>
> thanks!
>
>>
>>> 2) Is there any system that implements selector namespaces
>>> (beside Smalltalk/X :-) available so I can download it and
>>> play with it? If so, can you provide a link (then google-fu
>>> is apparently bad)
>>
>> ModularSmalltalk had selector namespaces. S# as well. Not the code is not available. I've heard that the author did not have the code as well.
>
> Yes, I know these two but no one is available, not even without its
> source code. Pity.
>
>>> 4) What happens if namespace Z imports both, X __and__ Y?
>>
>> You are here assuming that you can have multiple import of namespaces. I am not sure what happened with ModularSmalltalk, and S# always missed essential documentation to accurately answer this question.
>>
>> You have free room here!
> In this case, my implementation sends #ambiguousMessageSend: aMessage to
> the original receiver, which in turn raises AmbiguousMessageSendError,
> much like DNU mechanism.
>
>>
>>> 5) There are people out there saying "selector namespaces are cool
>>> because its implementation does not require changes to the VM.
>>> All you need is to change the compiler to prefix selectors with
>>> namespace..." (just like I did in my example). Then, how the namespace
>>> imports are/can be implemented?
>>
>> I know you said that :-)
>> Another implementation is you have an extra lookup (--> = lookup):
>> #bar --> #Y::bar --> compiled method
> ...which is another form of VM tweaking. For sake of completeness:
> one may instrument the code using call-site simulator objects. Not
> a way go in a long term, I think :-)
>
> What interests me is how use them in real life. How to partition the
> code among the namespaces, how to manage imports, is a really good idea
> to have "nothing or everything" import scheme, thinks like that...
>
> Anyway, thanks!
>
> Jan
>
>
>

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.





Reply | Threaded
Open this post in threaded view
|

Re: Selector Namespaces

stephane ducasse-2
In reply to this post by Jan Vrany
These are questions I'm interested in too.

Stef

On Sep 22, 2011, at 7:05 PM, Jan Vrany wrote:

> Hi,
>
> thanks!
>
>>
>>> 2) Is there any system that implements selector namespaces
>>> (beside Smalltalk/X :-) available so I can download it and
>>> play with it? If so, can you provide a link (then google-fu
>>> is apparently bad)
>>
>> ModularSmalltalk had selector namespaces. S# as well. Not the code is not available. I've heard that the author did not have the code as well.
>
> Yes, I know these two but no one is available, not even without its
> source code. Pity.
>
>>> 4) What happens if namespace Z imports both, X __and__ Y?
>>
>> You are here assuming that you can have multiple import of namespaces. I am not sure what happened with ModularSmalltalk, and S# always missed essential documentation to accurately answer this question.
>>
>> You have free room here!
> In this case, my implementation sends #ambiguousMessageSend: aMessage to
> the original receiver, which in turn raises AmbiguousMessageSendError,
> much like DNU mechanism.
>
>>
>>> 5) There are people out there saying "selector namespaces are cool
>>> because its implementation does not require changes to the VM.
>>> All you need is to change the compiler to prefix selectors with
>>> namespace..." (just like I did in my example). Then, how the namespace
>>> imports are/can be implemented?
>>
>> I know you said that :-)
>> Another implementation is you have an extra lookup (--> = lookup):
>> #bar --> #Y::bar --> compiled method
> ...which is another form of VM tweaking. For sake of completeness:
> one may instrument the code using call-site simulator objects. Not
> a way go in a long term, I think :-)
>
> What interests me is how use them in real life. How to partition the
> code among the namespaces, how to manage imports, is a really good idea
> to have "nothing or everything" import scheme, thinks like that...
>
> Anyway, thanks!
>
> Jan
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Selector Namespaces

Jan Vrany
On Thu, 2011-09-22 at 21:13 +0200, stephane ducasse wrote:
These are questions I'm interested in too.
>
>
> Keep us informed if you made some progress on that front.
> Indeed, how using SelectorNamespace is a topic that no many have
> worked on.

:-) Having answers is important, agree. But I feel the only way
how to find out answers is to start using them in our everyday work.
Do you see any other way?

Jan

Reply | Threaded
Open this post in threaded view
|

Re: Selector Namespaces

Alexandre Bergel-5
>> Keep us informed if you made some progress on that front.
>> Indeed, how using SelectorNamespace is a topic that no many have
>> worked on.
>
> :-) Having answers is important, agree. But I feel the only way
> how to find out answers is to start using them in our everyday work.
> Do you see any other way?


Some may say having a type system and a Coq proof will help :-) Just joking :-)

Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.





Reply | Threaded
Open this post in threaded view
|

Re: Selector Namespaces

stephane ducasse-2
In reply to this post by Jan Vrany
I think that building some realistic examples and perturbating them with potential evolution scenario
can be a good strategy.

Stef

On Sep 23, 2011, at 6:27 PM, Jan Vrany wrote:

> On Thu, 2011-09-22 at 21:13 +0200, stephane ducasse wrote:
> These are questions I'm interested in too.
>>
>>
>> Keep us informed if you made some progress on that front.
>> Indeed, how using SelectorNamespace is a topic that no many have
>> worked on.
>
> :-) Having answers is important, agree. But I feel the only way
> how to find out answers is to start using them in our everyday work.
> Do you see any other way?
>
> Jan
>