Larry,

On Sep 8, 2005, at 2:30 PM, Larry Wall wrote:
On Wed, Sep 07, 2005 at 03:00:29PM -0400, Stevan Little wrote:
: Also, is there anyway to iterate over the keys in the namespace? The
: old way would be to do something like keys(%Foo::). Is something like
: this possible with the new way?

Sure, it's still just a hash, basically, so Foo.keys() works fine.
All we've changed is that we've removed a special syntactic case by
allowing a type/package object to pretend to be a hash when used that way,
just as we allow it to pretend to be an undef when used as an instance.
Tagmemics strikes again...

But what if I want to do this?

class Foo {
        my %:stuff;
        method keys (Class $c:) {
                %:stuff.keys();
        }
}

How can I get at my namespace now? How would I disambiguiate that call? Doing something like Foo.Package::keys() seems to me to be exposing too much of the meta-level (the Package class).

I can see lots of potential conflict between class methods and methods to access the contents of a namespace (methods defined in the Hash role I assume). This means that Foo is getting even more and more magical. It's now a type annotation, a special undef value, the invocant in class methods and the "gatekeeper" of the namespace.

Stevan

Reply via email to