develooper Front page | perl.perl6.language | Postings from July 2006

Re: namespaces, a single colon to separate HLL prefix?

Thread Previous | Thread Next
Larry Wall
July 6, 2006 09:09
Re: namespaces, a single colon to separate HLL prefix?
Message ID:
On Thu, Jul 06, 2006 at 10:40:21AM -0400, Audrey Tang wrote:
: The : form is approved and canonical (line 303, the Modules spec, aka  
: version 14).
:     use perl5:DBI;
: However, currently it's only available at use/require line.   
: Afterwards, the user simply say:
:     my $dbh = DBI.connect(...);
: Though I think this:
:     my $dbh = perl5:DBI.connect(...)
: can be made to work, as it's currently parsefail, thought there is a  
: marginal case:
:     my $dbh = perl5:DBI; # currently parsed as perl5(:DBI)
: but we can say that for each HLL-qualified module name, it's a single  
: token and is therefore recognized first.
: Does that sound sane?  If yes, S11 can be updated to reflect that.

It's only sane if we require the predeclaration of the language higher
in the lexical scope.  Suppose we try to maintain a secret canonical
list, and then suppose someone adds a language 'q', for instance?
But after a "use q:mumble" we can certainly recognize "q:", presumably
forcing people to write "q :mumble" for the rest of the lexical scope
if they want a mumbled quote.  Alternately we could force explicit
declaration of all foreign namespaces:

    use namespace <perl5 q>;
    use q:QueryMe;
    use perl5:DBI;

Actually, I kinda like that because it gives a logical spot to talk
about how to import a namespace, if you want to modify it.  Like what
if you want to alias the namespace:

    use namespace :perl5<OldSchoolPerl>;

or some such.

But it's also possible we should do something more sigilistic or
twigilistic for foreign namespace roots.  A punishingly dehuffmanized
version might be

    use NAMESPACE::perl5::DBI;

which for alphabetic names the parser might allow us to reduce to

    use **perl5::DBI;

much like we allow *Foo as short for GLOBAL::Foo.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About