4 ms·
> Can one even use CPAN with Perl6? Is it even possible to convert existing Perl5 CPAN packages to support both versions at the same time (like all of the PyPI
by duskwuff 12y ago
> Can one even use CPAN with Perl6? Is it even possible to convert existing Perl5 CPAN packages to support both versions at the same time (like all of the PyPI packages that support both Python2 and Python3)?
Respectively: Not at all, and not without major contortions. The languages have diverged a lot; even basic tasks like defining a function are not the same.
- ugexe 12y agoRespectively: https://github.com/rakudo-p5/v5 https://github.com/rakudo-p5/v5 While not quite the same as what was asked, it's clear that 'not at all' is not an informed answer
- duskwuff 12y agoThat module's neat, but CPAN is still out of reach. For one, a lot of important modules in CPAN contain XS components, which don't carry over. Additionally, a lot of the modules that don't use XS are likely to be using unusual features of Perl5 which aren't fully emulated by that shim.
- ugexe 12y agoAs its now been pointed out more than once, 'not at all' is not true. I did not claim it could use everything available on CPAN, but was pointing out that you were making a false statement based on, well, i'm not sure what you based your statement on but it was made in such a matter-of-factly way that it needed to be corrected.
- raiph 12y agoYes. v5, a Perl 5 compiler written in Perl 6, is promising tech with potentially huge long term (10 years) strategic consequences for Perl 5 and Perl. But it's very early days and it correctly handles only the simplest of modules. I'd hazard a guess that currently less than 1% of CPAN modules pass their tests when loaded by v5. But Inline::Perl5 is a completely different animal. It handles modules using XS or whatever fine. See my nearby comments for further details.
- raiph 12y ago> Not at all [can one use CPAN] You are mistaken. See my nearby comment about Inline::Perl5. > not without major contortions [can one convert]. One doesn't need to convert (due to Inline::Perl5). That said there can be valid reasons (eg having fun and learning Perl 6) to want to convert existing Perl 5 code to a Perl 6 equivalent anyway. While some partial P5-to-P6 conversion tools already exist[1] (and I'd be surprised if more don't arrive in the future[2]), conversion of a well written Perl 5 module in to a well written Perl 6 module is mostly a manual exercise.[3] > even basic tasks like defining a function are not the same. sub foo ($foo, @bar) { my $qux; # do something return $qux } This is the same in both languages. Could you provide some code to illustrate what you mean? --- [1] http://www.perlito.org/perlito/perlito5to6.html http://www.perlito.org/perlito/perlito5to6.html Incomplete but better than nothing. [2] https://github.com/rakudo-p5/v5/ https://github.com/rakudo-p5/v5/ is a project to create a Perl 5 compiler written in Perl 6. It parses Perl 5 code and spits out Perl 6 ASTs. It's obviously not a huge jump for it to spit out straight Perl 6 code. One day... [3] http://jnthn.github.io/css-tiny-presentation/presentation/#/ http://jnthn.github.io/css-tiny-presentation/presentation/#/
- duskwuff 12y agoPerl5.18 has some limited support for Perl6-style function signatures, but it's still considered "experimental" and requires a pragma to enable. I don't consider that to really be part of the language yet; real-world Perl5 function definitions end up looking like this, at best: sub foo { my ($foo, @bar) = @_; ... } I'm not sure if that's valid syntax in Perl6 or not, but either way it's certainly not idiomatic.
- bmn_ 12y agoToo many people arguing about about function signatures are under the impression that this needs to be part of the core language. Turns out, it doesn't: Perl is flexible enough to have its syntax amended. As a practical programmer, I have enjoyed signatures and run-time type checking for years, provided by libraries. Even now, these libraries are more featureful than core signatures.
- 12y ago