develooper Front page | perl.perl6.language | Postings from May 2005

Re: Syntax of using Perl5 modules?

Thread Previous | Thread Next
From:
Dave Whipp
Date:
May 25, 2005 09:20
Subject:
Re: Syntax of using Perl5 modules?
Message ID:
20050525162044.3516.qmail@lists.develooper.com
Autrijus Tang wrote:
> So, this now works in Pugs with (with a "env PUGS_EMBED=perl5" build):
> 
>     use Digest--perl5;
> 
>     my $cxt = Digest.SHA1;
>     $cxt.add('Pugs!');
> 
>     # This prints: 66db83c4c3953949a30563141f08a848c4202f7f
>     say $cxt.hexdigest;
> 
> This includes the "Digest.pm" from Perl 5.  DBI.pm, CGI.pm etc will
> also work.
> 
> Now my question is, is my choice of using the "perl5" namespace indicator a 
> sane way to handle this?  Is it okay for Perl 6 to fallback to using Perl 5
> automatically?  Or should I use something else than "use" entirely?
> 

To my mind, the coupling seems wrong. If the "use" statement needs to 
state the language of the included module, then it would be difficult to 
later re-implement that module in p6.

My understanding is that there are clear rules (see S11) to distinguish 
p5 modules from p6: if the first keyword in the file is "module" or 
"class", then it's p6; otherwise assume p5.

Your use of hyphens puts your "perl5" indicator in the "URI" field 
(again, see S11), which is expected to refer to the author. "perl5" 
doesn't seem correct in this context. Even if you got rid of one of the 
hypthens (so that "perl5" is the "version"), then it still feels wrong. 
Each version of a module should be free to choose its language, but that 
should be encapsulated within the module.

If you do want to impose the language from the "use"er, the I'd expect 
an adverbial syntax: "use:p5 Digest;".


Dave.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About