On Thu, Sep 08, 2005 at 07:41:52PM -0400, Stevan Little wrote: : So it would be Foo::.keys() then? : : Would this be possible?
The more I think about it, the more I'm leaning toword postfix operators ::{} and ::<>, essentially in same syntactic niche as ::(). Which means you'd have to write that as Foo::{}.keys() If these are really postfix operators, then we can also write Foo .::{} Foo .::<> Foo .::() Postfix operators are expected in operator position. Note that ::{$ref} in term position actually requires a hard $ref inside instead of a key, so that's a slight inconsistency. But probably one we can live with. : my $pkg = Foo::; : # or maybe this ... : my $pkg = Foo<::>; If we went this way, that'd be: my $stash = Foo::{}; : Would $pkg be an instance of the Package class? I don't think so. I think that ::{} and ::<> would basically return the hash attribute in the Package object. So it's probably just Hash, or maybe Stash. : I would assume given : this code: : : package Foo { : ... : package Foo::Bar { : ... : } : } : : I can do this: : : my $pkg = Foo::{'::Bar'} : : And get back some kind of Package reference of some kind. Yes, that gives you the package. But my $stash = Foo::{'::Bar'}::{} would just give you the stash of the package. By the way, you don't have to write your inner package as Foo::Bar, since package/module/class declarations now assume "our". (File-scoped classes defaulting to * because that's the current package down to the first declaration in the file. Then the first declaration either switches explicitly to some package/module/class, or a "use v6" thingie implicitly switches to Main, or we're still in Perl 5's main.) : Do we even have first class packages? Sure. They should be as first class as modules or classes. But let us now say that a package ISn't Hash and DOESn't Hash. It merely HAS a private stash attribute that does Hash, which is made accessible (at least the public bits) via ::{}, ::<>, and ::(). Those operators can by default hide access to private ._fnord methods, for instance. And ::{}.keys would not tell you about private methods. Hmm, that seems a little difficult to implement. But hey, now that we've decoupled the stash from *being* the package object by making it an attribute, why don't we say that any ._fnordish things just get stuffed into a *different* stash attribute, and the ::{} can simply return the public stash without having to do any filtering. I think that's a lot cleaner. Larry