Jeff Clites writes:
> On Sep 12, 2004, at 8:43 PM, Luke Palmer wrote:
> 
> >Jeff Clites writes:
> >>On Sep 7, 2004, at 6:26 AM, Dan Sugalski wrote:
> >>
> >>>*) Namespaces are hierarchical
> >>>
> >>>So we can have ["foo"; "bar"; "baz"] for a namespace. Woo hoo and all
> >>>that. It'd map to the equivalent perl namespace of foo::bar::baz.
> >>
> >>How does this hierarchical nature manifest? I ask because I don't know
> >>of any languages which actually have nested namespaces,
> >
> >Other than, um, well, Perl.
> 
> As an implementation detail yes, but I can't think of any Perl code 
> (except for explicit introspection) which "reveals" this. 

Does:

    print ${$Foo::{"Bar::"}{baz}}

Count as explicit introspection?

> >No, the lookup is not cascading downwards.  It is cascading upwards,
> >however, so that in:
> >
> >    [ "foo"; "bar"; "baz" ]
> >
> >The [ "foo"; "bar" ] part can be implemented differently.  This means
> >that Python's namespaces and Perl's namespaces can have different
> >semantics.  Picture a PythonStash and PerlStash pmc.
> 
> Now it's true that if you think it's really important to tie
> namespaces such that you can take over the name resolution for
> ["Foo"], then you'd want the former. But I don't see that as really
> terribly useful

A debugger.

No, let me restate.

A DEBUGGER!

> --in the examples I've heard of (e.g., turning the namespace lookup
> into an Oracle fetch) have seemed to not provide much that a tied hash
> doesn't.  And there are currently a ton of, for instance, Text::Blah
> modules on CPAN--but that doesn't actually mean that they have
> anything to do with a "Text" namespace--that's not the intention, and
> most of these modules have nothing to do with each other. That naming
> is to keep them conceptually organized, not functionally.

Sure.  That's not the idea behind the heirarchical namespaces either.  A
lot of power comes out of being able to treat namespaces as a tree-like
data structure (I can actually attest to this: see Class::Closure), as
was pointed out before, being able to treat namespaces as a filesystem.

Also, Perl 6's classes will behave more heirarchically:

    module Foo;
    
    class Bar {...}
    my $x = Bar.new;   # Actually works, while Bar is Foo::Bar.

I don't know how much that says for my argument though.

Luke

Reply via email to