Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^4: A wholly inadequate reply to an Anonymous Monk

by Anonymous Monk
on Apr 23, 2010 at 08:53 UTC ( #836469=note: print w/ replies, xml ) Need Help??


in reply to Re^3: A wholly inadequate reply to an Anonymous Monk
in thread A wholly inadequate reply to an Anonymous Monk

Will Perl 6 be compatible with existing CPAN modules, I mean CPAN modules for Perl 5?


Comment on Re^4: A wholly inadequate reply to an Anonymous Monk
Re^5: A wholly inadequate reply to an Anonymous Monk
by moritz (Cardinal) on Apr 23, 2010 at 09:08 UTC
    See S01 for the answer.
      S01 says "we sure wish so".

      As for it actually happening..

      Perl 6 has drastically different calling conventions than Perl 5, and even now has characters in its standard library functions that are prohibited in Perl 5 ("-"). The only way I see them inter-operating is through some hairy foreign function interface. Let's take this example from S01:

      use v6; # ...some Perl 6 code... { use v5; # ...some Perl 5 code... { use v6; # ...more Perl 6 code... } }
      How would this work with some real code dropped in:
      use v6; multi sub foo-bar(Str $a, Str $b) { "str/str" } multi sub foo-bar(Str $a, Int $b) { "str/int" } multi sub foo-bar(Str $a, Num $b) { "str/num" } multi sub foo-bar(Str $a, Array $b) { "str/num" } { use v5; # oh shit, what now? do I: foo-bar("1", "2"); # syntax error call_perl6_func("foo-bar", "1", "2"); # calls, but breaks sinc +e Perl5 has no types # Maybe this instead: call_perl6_func("foo-bar", Perl6cast("Str", "1"), Perl6cast("S +tr", "2"); { use v6; # now how do I call perl 5? } }
      That's just the simple case of calling a subroutine. How about the totally incompatible object systems?

      Does someone have a plan for getting this working?

        The dash syntax one was straightforward. This works in Perl 5:

        *{"foo-bar"} = sub { "Hello, @_!\n" }; print &{"foo-bar"}('world');

        It might work in Perl 4 or even Perl 3, but I had not verified yet... :-)

        As for object systems: Well, the very notion of "object systems" means "interfaces as types", and it's precisely across those interfaces we bridge between calling conventions.

        Please refer to William Cook's slides and essay for more rigorous explanations of the interface/OO link.

        So in that sense, there are really no totally incompatible object systems, since any two such systems can embed one another using cross-system meta-object protocol.

        And as for the type-based multi-dispatch case, we can observe below that Perl 5 does have the notion of runtime types:

        A:~ au$ perl -MDevel::Peek -e 'Dump 3' SV = IV(0x100827190) at 0x100827198 REFCNT = 1 FLAGS = (IOK,READONLY,pIOK) IV = 3 A:~ au$ perl -MDevel::Peek -e 'Dump "3"' SV = PV(0x100801258) at 0x1008271b0 REFCNT = 1 FLAGS = (POK,READONLY,pPOK) PV = 0x100207f60 "3"\0 CUR = 1 LEN = 16

        Note that the IV above refers to an integer type, and PV refers a stringish type. (cf. perlguts for details...)

        As for the casting functions, Perl 5 has them built-in:

        "".$x # to string 0+$x # to number int($x) # to integer

        Hope that helps! :-)

Re^5: A wholly inadequate reply to an Anonymous Monk
by BerntB (Deacon) on Apr 23, 2010 at 13:43 UTC

    I think Worthington++ started some strangely named project this autumn to link Perl 5 into Parrot, as an "equal" language. So evals and function/method calls should be doable, then. (Failed to google it right now.)

    Edit: Thx, Audrey++

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://836469]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-10-23 05:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (124 votes), past polls