Are perl5 libraries are importable in perl6?

2019-02-23 21:48发布

I know that perl6 will definetely allow importing perl5 code but I'm not able to do this.

Here is perl6 code

use perl5:Net::FTP;

It reports an error

Is there any configuration issue or it is not ready yet?

标签: perl6 perl5
2条回答
我想做一个坏孩纸
2楼-- · 2019-02-23 22:12

Inline::Perl5

As of late 2014, for most purposes, for most folk, Inline::Perl5 is the way to go to use P5 code in P6 and vice-versa, including useing P5 libraries in P6.

Inline::Perl5 appropriately packages and wraps a regular perl5 interpreter in MoarVM so that the P6 compiler Rakudo can interop with P5. The combination already supports:

  • useing Perl 5 modules, including ones that use XS, in Perl 6
  • manipulating P5 objects in P6 and vice-versa
  • writing, in P6, sub-classes of Perl 5 classes

nine, the module's author, who had never written P6 code before he started Inline::Perl5, has done some presentations that are available on youtube:

v5

The v5 project, as discussed in teodozjan's answer, is a very different technology with very different use cases, mostly (but not entirely) unrelated to the SO question this post is answering.

v5 is a start-from-scratch re-implementation of a Perl 5 interpreter/compiler. v5 currently parses and compiles enough pure Perl 5 code to pass a few thousand tests in the regular perl5 test suite and to use some simple Perl 5 modules. It was originally written in NQP (in 2013) and then ported to full Perl 6 in 2014.

The module's author, FROGGS, has mostly paused developing it while he works on other more urgent pieces of P6. But it's already a substantial project that has driven various Perl 6 features forward, especially the slang feature. Long term v5 may yield a complete new Perl 5 implementation. (But without bug-for-bug compatibility or (direct) support for XS.)

FROGGS has done some presentations on v5 including this 20 minute video introducing v5 in 2013.

nine has suggested v5 can be used to add sugar to Inline::Perl5 and Inline::Perl5 can give v5 some extra options too, so these two projects may end up helping each other along.

blizkost

The first Rakudo based P5/P6 interop project was "blizkost". This project allowed single strings of Perl 5 code to be executed on old versions of Rakudo on the Parrot VM (circa 2010). I believe it does not work on current versions and has been obsoleted by Inline::Perl5.

查看更多
一夜七次
3楼-- · 2019-02-23 22:17

According to perlwiki

note: As of May 2012, none of the Perl 6 compilers yet implement this feature.

According to adventcalendar

Some basic modules are usable through slang feature but only a few of them like Config, Cwd and English are available.

查看更多
登录 后发表回答