Leopold Toetsch writes: > I'd add some syntax additions and some notes: > > - Pn above is a NameSpace PMC, derived from Hash > - an interpreter has a current namespace > - located in the context, so that its restored after sub calls > > getinterp P2 > find_global Pn, P2["."] # get current NS > find_global Pz, P2[".."] # get parent NS > set Pz, Pn[".."] # same > find_global Py, P2["/"] # get root of namespaces > find_global Px, Pn["Foo"; "Bar"] # NS of Module Foo::Bar > find_global Pv, Pn["Foo"; "Bar"], "baz" # $Foo::Bar::baz var > find_global Pv, Pn["Foo"; "Bar"; "baz" ] # same > set P2["."], Px # switch current NS to Foo::Bar > find_global Pv, Pn["/"; "java"; "some"; "glob" ] # /java.some.glob
ÂMe gusta mucho! This system allows neato things like anonymous namespaces, too. I was thinking of something similar for classes. An object holds a reference to a class PMC which is used to fetch its methods. This allows different metaclasses (which are, again, required for Perl 6[1]). Maybe said class PMC is, by default, just an anonymous namespace PMC. Luke