From: Charles Oliver Nutter Date: 2009-02-27T03:22:53+09:00 Subject: [ruby-core:22549] Re: YASNP (Yet Another Selector Namespace Proposal) Austin Ziegler wrote: >> obj.(bar) >> >> where means "symbol foo in that namespace", and its >> correspondence can be modified by (dynamic) method definitions. > > Is there any reason that the above can't be made a valid syntax? I > realize that we would also want a way to magic it so that we're not > always having to type when we want to apply the #foo > from namespace to obj, but I think that's part of what's been > bothering me about this proposal: this seems harder to track down than > necessary when bug fixing. This exact syntax as written has a number of problems: obj.< is a valid call obj.(bar) is obj < namespace::foo > (bar) Lots of ambiguities. If instead we're talking about a version withing angle brackets: obj.namespace::foo(bar) is already valid syntax, equivalent to obj.namespace.foo(bar). > I'm also not sure that file-based lexical scoping is entirely what we > want. What do we want here: > > require 'my-namespace' > using My::Namespace => String; > require 'external-dependency' > require 'my-dependency' > > If I'm a library writer, I'm not sure whether I want to have to > specify the "using My::Namespace" line in each of my internal > dependencies, but at the same time I don't want such things to go into > external dependencies, either. I think the important aspect of this is that it's patching writ small. The fact that you specify it only in the files where you need it is a key feature. > I'm not opposed to selector namespaces, but I think I worry a little > that a lot of the discussion has been focussing on what > framework/library writers would do���presumably we're advanced > programmers and won't make silly mistakes���and not a lot of thought as > to how a facility might be abused. I think there's actually quite a bit of discussion about how it could be abused, but I don't think we're heard a lot of specific examples. Do you have one in mind? - Charlie