From: Ola Bini Date: 2009-02-26T06:11:50+09:00 Subject: [ruby-core:22506] Re: YASNP (Yet Another Selector Namespace Proposal) Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:22490] Re: YASNP (Yet Another Selector Namespace Proposal)" > on Thu, 26 Feb 2009 04:08:19 +0900, Ola Bini writes: > > |If any of this has been answered, or if I misunderstood something, I > |apologize in advance: > > Here's MY opinion. > > |- How would this interact with send? > > send should honor namespaces. > > |- How would it interact with other introspection facilities? Kernel#method ? > | Basically, what is the runtime behavior of all metaprogramming and > |introspection features here... > > and other introspection features as well. > > |- Do I understand correctly that this is supposed to be a lexical > |effect, and not a dynamic one? > > I think so. > OK, my main question about how this should work then is basically that to support a lexically scoped feature for dynamic methods (such as send and method_missing and things like that) all the code within the selector namespace need to capture lexical scope. That is one of the reasons that packages in Common Lisp turn out to be so complicated, and is still a static feature in most cases. > | ... in that case I have no idea how it's supposed to work at parse > |time. > > One possible idea is making symbols to belong to each namespace, like > Common Lisp does, in that case, > > obj.foo(bar) > > should be work as > > obj.(bar) > > where means "symbol foo in that namespace", and its > correspondence can be modified by (dynamic) method definitions. > > I definitely like this thinking. As I see a selector proposal, it basically works like this: every method call has an associated namespace. that namespace defaults to the Parsing Default for that file. if a namespace is set for a file, then THAT namespace will be the Parsing Default for that file. of course, this means that namespaces/selectors should just be names - not modules. When you start having modules as namespaces, then it gets really complicated to see what is actually scoped inside of another namespace or not, since the parser can't know this. Cheers -- Ola Bini (http://olabini.com) Ioke creator (http://ioke.org) JRuby Core Developer (http://jruby.org) Developer, ThoughtWorks Studios (http://studios.thoughtworks.com) Practical JRuby on Rails (http://apress.com/book/view/9781590598818) "Yields falsehood when quined" yields falsehood when quined.