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

2006-07-06 Thread Aaron Sherman
On Thu, 2006-07-06 at 09:09 -0700, Larry Wall wrote:
> 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  
> : S11.pm version 14).
> : 
> : use perl5:DBI;
[...]
> : 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.

Namespaces aren't your only concern here. You also care about all of the
semantics of module loading and the integration of the target language's
module loading semantics with Perl 6's. For example, there's a
completely separate search path for Perl 5 modules, and an implicit
invocation of a package method that might not happen in P6. I think what
you want to be saying is not, "use DBI from the Perl 5 namespace", but
"invoke the Perl 6 / Perl 5 module loader interface for DBI".

That's really something like:

use Lang::Perl5::Loader;
perl5use DBI;

That we provide a shortcut called "use perl5:DBI" is just sugar, and we
might provide that for many languages. However, the user should know how
to do it the "hard way" in case they want to talk to a less officially
blessed language:

use Lang::Bash::Loader;
use Lang::Elisp::Loader;
bashuse "~/.bashrc";
elispuse "hanoi";
say %*ENV{PATH}
hanoi(13);

Inventing syntactic sugar for the back-end case probably doesn't buy you
anything special.

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"We had some good machines, but they don't work no more." -Shriekback




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

2006-07-06 Thread Larry Wall
On Thu, Jul 06, 2006 at 09:09:08AM -0700, Larry Wall wrote:
: use **perl5::DBI;

which, if you don't like the two-character form, you can spell:

⁑perl5::DBI

:-)

Hmm, hmm, speaking of sanity, how 'bout user-defined sigils and twigils:

sigil ¢ = Capture;
twigil ¬ = "NOTREALLY::";
¢¬foo;  # not really a capture...  :)

Larry


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

2006-07-06 Thread Larry Wall
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  
: S11.pm 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 ;
...
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;

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.

Larry


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

2006-07-06 Thread Audrey Tang


在 2006/7/6 上午 3:30 時,Allison Randal 寫到:

Quick question, is there a syntax specified in Perl 6 for referring  
to namespaces from other languages?


I'm reviewing the namespaces PDD and want to update this snippet:
--
IMPLEMENTATION EXAMPLES: Suppose a Perl program were to import some  
Tcl module with an import pattern of ``c*'' -- something that might  
be expressed in Perl 6 as use tcl:Some::Module 'c*'. This operation  
would import all the commands that start with 'c' from the given  
Tcl namespace into the current Perl namespace. This is so because,  
regardless of whether 'c*' is a Perl 6 style export pattern, it is  
a valid Tcl export pattern.


{XXX - Is the ':' for HLL approved or just proposed? Somebody  
familiar with Perl 6 please fix the example in the preceding  
paragraph to use the currently planned syntax for importing modules  
from other languages.}

--


The : form is approved and canonical (line 303, the Modules spec, aka  
S11.pm 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.

Thanks,
Audrey

PGP.sig
Description: This is a digitally signed message part


namespaces, a single colon to separate HLL prefix?

2006-07-06 Thread Allison Randal
Quick question, is there a syntax specified in Perl 6 for referring to 
namespaces from other languages?


I'm reviewing the namespaces PDD and want to update this snippet:
--
IMPLEMENTATION EXAMPLES: Suppose a Perl program were to import some Tcl 
module with an import pattern of ``c*'' -- something that might be 
expressed in Perl 6 as use tcl:Some::Module 'c*'. This operation would 
import all the commands that start with 'c' from the given Tcl namespace 
into the current Perl namespace. This is so because, regardless of 
whether 'c*' is a Perl 6 style export pattern, it is a valid Tcl export 
pattern.


{XXX - Is the ':' for HLL approved or just proposed? Somebody familiar 
with Perl 6 please fix the example in the preceding paragraph to use the 
currently planned syntax for importing modules from other languages.}

--

Thanks,
Allison