On Thu, Dec 12, 2002 at 12:40:52PM -0600, Garrett Goebel wrote:
: John Siracusa wrote:
: > On 12/12/02 12:55 PM, Larry Wall wrote:
: > > As for namespace pollution and classes that use .id in Perl 5, I
: > > don't think it's going to be a big problem.  Built-in identifiers
: > > do not have a required prefix, but they have an optional prefix,
: > > which is C<*>.  I think we can probably parse
: > > 
: > >   $a.*id == $b.*id
: > > 
: > > if you really need to get to Object.id().
: > 
: > That'll only work out if everyone always writes it as "*id".  
: > If not, my Perl 6 objects that override "id()" won't work correctly
: > with any other classes or functions that simply call "id" and
: > expect it to really be "*id"
: 
: yes...
: 
: So we'll _have_ to write $obj.*id when we mean $obj->UNIVERSAL::id;

If you wish to be precise, yes.  But $a.id eq $b.id should work for most any
class that uses the the term "id" in the typical fashion.

: I'm not sure I understand what Larry means by "most-global"... Do you mean
: outer-most scope, root-of-method-inheritence, or both?

It's context dependent, just as the meaning of an identifier is context dependent.
In this case, it means root-of-method-inheritance, that is, Object.  (That is
tne new name of UNIVERSAL.)  So $a.*id is short for $a.Object::id.  But $*foo
is short for $Global::foo or some such.

: And what of the case we someone does want to explicitly override a "builtin"
: method like UNIVERSAL::can? What is the Perl6 equivalent to:
: 
:   *UNIVERSAL::can = sub { print qq{hello\n} };
:   sub foo {};
:   print main->can('foo')";

Any of:

    method Object::can ($meth) { print qq[hello\n] }

or

    &*can := method ($meth) { print qq[hello\n] };

or

    &Object::can ::= sub ($object, $method) { print qq[hello\n] };

Hmm.  Those don't really stand out enough.  Maybe we should go with
OBJECT:: and GLOBAL:: just for a little more visual punch.

: And what will:
: 
:   main.*can('foo')
: 
: result in?

These days it's "Main", not "main".  And it's a module, not a class,
so probably it fails, unless someone can think of something useful
for it to mean.

: Larry Wall wrote:
: > 
: > I'd almost be tempted to argue that if push comes to shove, it's
: > the list splat star that gets shoved.
: 
: Don't you suspect the list splat will be more common than most-global?

That's why I said "almost".

Larry

Reply via email to