v6 - An experimental Perl 6 implementation
# file: hello_world.pl use v6-alpha; "hello, world".say; $ perl hello_world.pl
v6-alpha can be used in one-liners:
v6-alpha
$ perl -e 'use v6-alpha' ' 42.say ' $ perl -e 'use v6-alpha' - ' 42.say ' $ perl -e 'use v6-alpha' - --compile-only ' 42.say ' $ perl -e 'use v6-alpha' - -Ilib6 ' 42.say ' $ echo 42.say | perl -e 'use v6-alpha'
v6.pm can also be used as a plain program. This examples assume that v6.pm is in the ./lib directory:
v6.pm
./lib
$ perl lib/v6.pm -e 'for 1,2,3 -> $x { say $x }' $ perl lib/v6.pm --compile-only -e '<hello>.say;'
Print the version banner:
$ perl -e 'use v6-alpha' - -v $ perl lib/v6.pm -v
The v6 module is a front-end to the experimental Perl6-to-Perl5 compiler.
v6
The current state of this compiler implementation only provides a small sample of Perl 6 syntax and semantics.
Pugs Perl 6 is currently the most complete implementation. Pugs is written on top of Haskell.
Pugs
Perl 6 on Parrot aims to become the best performing implementation. Parrot is a virtual machine designed to efficiently compile and execute bytecode for interpreted languages.
Parrot
v6.pm is completely independent of Pugs or Parrot.
Pugs::Compiler::Rule provides an implementation for Perl 6 Rules, which are used to define the Perl 6 grammar.
Parse::Yapp is used for implementing the operator precedence parser.
Module::Compile and Cache::Cache provide the precompilation cache infrastructure.
The object system is provided by Moose. Moose is an extension of the Perl 5 object system. Moose is built on top of Class::MOP, which is a metaclass system for Perl 5.
Data::Bind and Sub::Multi implement the semantics for perl6-style variable binding, as well as subroutine call argument passing and binding, in Perl 5.
- The source file header must be valid perl5 and perl6 code.
This is a valid header:
#!/usr/bin/perl use v6-alpha;
* it executes perl5
* perl5 will call the v6.pm module.
This is an invalid header:
#!/usr/bin/pugs use v6;
* it tells perl5 to execute /usr/bin/pugs.
/usr/bin/pugs
* it tells perl5 that Perl v6.0.0 required.
- The Pugs::Compiler::Rule module must be properly installed.
Pugs::Compiler::Rule
An improperly installed Pugs::Compiler::Rule module would prevent the Perl 6 compiler from bootstrapping.
If that is the case, running Makefile.PL and make in Pugs::Compiler::Rule should fix the problem.
Makefile.PL
make
- The perl5 executable must have PMC support.
PMC support is required for loading precompiled Perl 6 files.
If you see the error below, it may happen that your perl was compiled without PMC support.
Can't locate object method "compile" via package "Pugs::Compiler::Perl6"
Please see http://rt.cpan.org/Public/Bug/Display.html?id=20152
* PERL6LIB
Same usage as PERL5LIB - sets the search path for Perl 6 modules.
* V6DUMPAST
If set, the compiler will dump the syntax tree to STDOUT just before emitting code, using Data::Dumper.
STDOUT
Data::Dumper
* V6TIDY
If set, the compiler output will be much more readable, but there will be a lot of slowdown in compiler speed.
* --compile-only
When using v6.pm from the command line, dumps the emitted code to STDOUT and then exit:
$ perl -e 'use v6-alpha' - --compile-only ' 42.say ' $ perl -Ilib lib/v6.pm --compile-only -e '<hello>.say;'
* -B
Selects alternate code generation backends.
The default is '-Bperl5:Pugs::Emitter::Perl6::Perl5'. '-Bperl5' also invokes the default backend.
$ perl -e 'use v6-alpha' - --compile-only -Bperl5:MyEmitter ' 42.say '
The backend module must provide the emit($grammar, $ast) subroutine.
emit($grammar, $ast)
* -G
Selects alternate grammar frontends.
The default is '-Gperl5:Pugs::Grammar::Perl6'.
The Pugs Team <perl6-compiler@perl.org>.
The Perl 6 homepage at http://dev.perl.org/perl6.
- the Perl 6 Synopsis: http://dev.perl.org/perl6/doc/synopsis.html.
The Pugs homepage at http://pugscode.org/.
The Parrot homepage at http://www.parrotcode.org.
Copyright 2006 by Flavio Soibelmann Glock and others.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install v6, copy and paste the appropriate command in to your terminal.
cpanm
cpanm v6
CPAN shell
perl -MCPAN -e shell install v6
For more information on module installation, please visit the detailed CPAN module installation guide.