Re: is there a Perl 5 converter?
On 21 January 2016 at 01:40, Darren Duncanwrote: > On 2016-01-20 5:02 PM, ToddAndMargo wrote: >> >> or is it all by hand? > > > If you mean a source code translator, I don't know of one right now but I > wouldn't be surprised if one exists, that at least handles a common subset > of Perl 5 code. I expect having one will be a priority if it isn't around > now. There are at least two source code translators in progress: http://search.cpan.org/dist/Perl-ToPerl6/ https://github.com/Util/Blue_Tiger/ They probably help but I'd be surprised if they work particularly well yet in producing code which runs straight off. -- 4096R/EA75174B Steve Mynott
Re: is there a Perl 5 converter?
On Jan 21, 2016, at 2:36 AM, Steve Mynottwrote: > On 21 January 2016 at 01:40, Darren Duncan wrote: >> On 2016-01-20 5:02 PM, ToddAndMargo wrote: >>> >>> or is it all by hand? >> >> >> If you mean a source code translator, I don't know of one right now but I >> wouldn't be surprised if one exists, that at least handles a common subset >> of Perl 5 code. I expect having one will be a priority if it isn't around >> now. > > There are at least two source code translators in progress: > > http://search.cpan.org/dist/Perl-ToPerl6/ > > https://github.com/Util/Blue_Tiger/ > > They probably help but I'd be surprised if they work particularly well > yet in producing code which runs straight off. I am the author of one of the translators (Blue Tiger), and I welcome feedback on which parts are missing that would (be|have been) useful to you; it will help me prioritize development. For automated translation, see http://docs.perl6.org/language/5to6-nutshell#Automated_Translation Blue Tiger (p526) and Perl-ToPerl6 (perlmogrify) are the most useable. Perlito's website is down. ( For manual translation, read all of the 5to6-* docs at the top of http://docs.perl6.org/language.html , or email me ). Below, I have a terminal log of installation and execution of both translators. $ cat >example.pl < $c { "$c$c$c\n".print(); } $ git clone git://github.com/Util/Blue_Tiger.git $ cd Blue_Tiger $ bin/p526 ../example.pl my @aaa = < a b c d e f g >; for @aaa <-> $c { print "$c$c$c\n"; } -- Hope this helps, Bruce Gray (Util on IRC)
Re: is there a Perl 5 converter?
On Thursday, January 21, 2016, Bruce Graywrote: > On Jan 21, 2016, at 2:36 AM, Steve Mynott wrote: > > On 21 January 2016 at 01:40, Darren Duncan wrote: > >> On 2016-01-20 5:02 PM, ToddAndMargo wrote: > > There are at least two source code translators in progress: > > http://search.cpan.org/dist/Perl-ToPerl6/ > > https://github.com/Util/Blue_Tiger/ ... > I am the author of one of the translators (Blue Tiger), > and I welcome feedback on which parts are missing that > would (be|have been) useful to you; it will help me prioritize development. > > For automated translation, see > http://docs.perl6.org/language/5to6-nutshell#Automated_Translation >Blue Tiger (p526) and Perl-ToPerl6 (perlmogrify) are the most useable. >Perlito's website is down. > > ( For manual translation, read all of the 5to6-* docs at the top of > http://docs.perl6.org/language.html , or email me ). > > Below, I have a terminal log of installation and execution of both > translators. .. Perl 5 source == > my @aaa = qw( a b c d e f g ); > for my $c (@aaa) { Perl::ToPerl6 = > my @aaa = qw ( a b c d e f g ); > for (@aaa) -> $c { Blue_Tiger > my @aaa = < a b c d e f g >; > for @aaa <-> $c { For the example Perl 5 input I like the Blue_Tiger translation, except I haven't so far found an description of the '<->' operator. Why would Blue_Tiger prefer it to the '->' operator which I've seen in all the examples I can remember seeing? Thanks. Cheers! -Tom
Re: is there a Perl 5 converter?
Tom Browderwrites: > Perl 5 source > == >> my @aaa = qw( a b c d e f g ); >> for my $c (@aaa) { > > Perl::ToPerl6 > = >> my @aaa = qw ( a b c d e f g ); >> for (@aaa) -> $c { > > Blue_Tiger > >> my @aaa = < a b c d e f g >; >> for @aaa <-> $c { > > For the example Perl 5 input I like the Blue_Tiger translation, except > I haven't so far found an description of the '<->' operator. Why > would Blue_Tiger prefer it to the '->' operator which I've seen in all > the examples I can remember seeing? In Perl 5, the loop variable ($c) is an alias into the array, and changing its value changes the the value in the array. In Perl 6, the array being worked on is read-only by default, so in the Perl::ToPerl6 example, trying to change the value of $c inside the loop would throw an error. Using the <-> operator (also pointing back from the loop variable to the array) tells it to use the Perl 5 behavior, where the array can be changed by changing the loop variable. -- Aaron -- aaron.baugher.biz
Re: is there a Perl 5 converter?
On Thu, Jan 21, 2016 at 12:00 PM, Aaron Baugherwrote: > Tom Browder writes: ... >> For the example Perl 5 input I like the Blue_Tiger translation, except >> I haven't so far found an description of the '<->' operator. Why >> would Blue_Tiger prefer it to the '->' operator which I've seen in all >> the examples I can remember seeing? > > In Perl 5, the loop variable ($c) is an alias into the array, and changing > its value changes the the value in the array. In Perl 6, the array being > worked on is read-only by default, so in the Perl::ToPerl6 example, trying to > change the value of $c inside the loop would throw an error. Using the <-> > operator (also pointing back from the loop variable to the array) tells it to > use the Perl 5 behavior, where the array can be changed by changing the loop > variable. Thanks, Aaron, good explanation. But can you find a description of '<->' in the Perl 6 docs? I did a search here https://raw.githubusercontent.com/perl6/mu/master/docs/Perl6/Cheatsheet/cheatsheet.txt here https://doc.perl6.org/language/operators and here: https://doc.perl6.org/language.html and couldn't find it. Cheers! -Tom
Re: is there a Perl 5 converter?
Tom Browderwrites: > Thanks, Aaron, good explanation. But can you find a description of > '<->' in the Perl 6 docs? It's mentioned here: https://doc.perl6.org/language/control#for And here, where it's called the "double-ended arrow", though I don't know how official that name is: https://design.perl6.org/S04.html#The_for_statement I don't know if it's actually an operator, which may be why it's hard to find. -- Aaron -- aaron.baugher.biz
Re: is there a Perl 5 converter?
On Thu, Jan 21, 2016 at 1:39 PM, Aaron Baugherwrote: > Tom Browder writes: > >> Thanks, Aaron, good explanation. But can you find a description of >> '<->' in the Perl 6 docs? > > It's mentioned here: https://doc.perl6.org/language/control#for ... > I don't know if it's actually an operator, which may be why it's hard to find. Thanks, Aaron! -Tom
Re: is there a Perl 5 converter?
On Thu, Jan 21, 2016 at 01:39:15PM -0600, Aaron Baugher wrote: > Tom Browderwrites: > > > Thanks, Aaron, good explanation. But can you find a description of > > '<->' in the Perl 6 docs? > > It's mentioned here: https://doc.perl6.org/language/control#for > > And here, where it's called the "double-ended arrow", though I don't know how > official that name is: https://design.perl6.org/S04.html#The_for_statement > > I don't know if it's actually an operator, which may be why it's hard to find. '<->' isn't an operator, it's one of the tokens that introduces a pointy block term. It's the "default to rw" form of '->' for declaring a block with parameters. Pm
Re: is there a Perl 5 converter?
On 2016-01-20 5:02 PM, ToddAndMargo wrote: or is it all by hand? If you mean a source code translator, I don't know of one right now but I wouldn't be surprised if one exists, that at least handles a common subset of Perl 5 code. I expect having one will be a priority if it isn't around now. Maybe around 5 years ago I recall that the Perl 5 interpreter was updated to retain all source metadata in its parse tree partly so that this could be a basis to generate the original Perl 5 source, or alternately generate corresponding Perl 6 from it. See also the CPAN module PPI which may be a basis for one. You may not need a source translator though. The Perl 6 module Inline::Perl5 lets you simply use Perl 5 modules in Perl 6 programs as if they were Perl 6 modules. The source translation I'm aware of is generally by hand, and often people doing it are also doing significant rewrites to take better advantage of the new Perl 6 features and idioms that a more mechanical automatic translation wouldn't. Did that tell you anything useful? -- Darren Duncan