At 12:06 PM +0800 5/25/05, 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?
Thanks,
/Autrijus/

I would say that one should always have to specify the Perl 5 namespace in some way, so that there are no surprises as to whether something you invoke is implemented in Perl 6 or Perl 5, and so that it is possible to be actively using a Perl 5 and Perl 6 module with the same short name at the same time.

Do not fallback to it automatically.

Rather, if someone wanted to not fill their Perl 6 code with "--perl5", they should use the Perl 6 feature that lets you create lexical aliases to things; they can explicitly declare a Perl 6 name for what they want to use, which just so happens to be an alias for the Perl 5 implementation.

I won't suggest exact syntax here, though yours looks fine for now.

Separately, since this together with the earlier 'inline' feature for Perl 5 sort of completes a circle of Pugs->Perl5->Pugs or Perl5->Pugs->Perl5, I see a further improvement that could possibly be made, if it isn't already.

That is, when you have three-somes like that, let the two endmost Pugs, or endmost Perl5, be the exact same interpreter in memory. So that, eg, if you set a global var in the caller-most Perl5, it will be visible in the called-most Perl5, or vice-versa.

On the other hand, I don't know whether or not that would be better in practice than keeping separate interpreters for calling and called.

-- Darren Duncan

Reply via email to