News for hackers. Stuff that matters.
Re:Differences Between Perl 5 and Perl 6 by Paul_S on Wednesday October 07, 2015 @10:17AM (#10346134)
One thing that bugs is that perl5 code could potentially run with perl6. Is there any mitigation for that?
Re:Differences Between Perl 5 and Perl 6 by jayvanguard on Wednesday October 07, 2015 @10:51AM (#10346353)
It was explicitly not a design goal to be backwards compatible.

"In exchange for breaking backwards compatibility, at least at the language level, Perl 6 offers plenty of high-powered language concepts that Perl 5 didn't support..."

http://www.perl.com/pub/2006/01/12/what_is_perl_6.html

Re:Differences Between Perl 5 and Perl 6 by maw on Wednesday October 07, 2015 @11:01AM (#10346412)
That's not what I read the GP post as saying though. Rather, that the perl 6 interpreter could run code written as perl 5 (and never ported). With their different semantics, the results would be unpredictable and often undesired.
Re:Differences Between Perl 5 and Perl 6 by kylebgorman on Wednesday October 07, 2015 @11:24AM (#10346550)
From this document, the chance that a perl 5 script is syntactically valid (but semantically different) perl 6 is awfully low. Now if the errors that arose said that you might be trying to execute perl 5 as perl 6, that'd be cool ;)
Re:Differences Between Perl 5 and Perl 6 by donaldihunter on Wednesday October 07, 2015 @11:58AM (#10346764)
There are numerous error messages that highlight perl 5 isms

e.g.

  > say $#array;
  ===SORRY!=== Error while compiling <unknown file>
  Unsupported use of $#variable; in Perl 6 please use @variable.end
and

  package foo;
  ===SORRY!=== Error while compiling <unknown file>
  This appears to be Perl 5 code. If you intended it to be Perl 6 code, please use a Perl 6 style declaration like "unit package Foo;" or "unit module Foo;", or use the block form instead of the semicolon form.
Re:Differences Between Perl 5 and Perl 6 by amyjess on Wednesday October 07, 2015 @12:31PM (#10346986)
Yes, these suggestions are among my favorite things about Rakudo.

There are a lot more, too. Another example:

    > 1 == 1 ? "sane" : "insane"
    ===SORRY!=== Error while compiling <unknown file>
    Unsupported use of ? and : for the ternary conditional operator; in Perl 6 please use ?? and !!
    at <unknown file>:1
Or:

    > loop(my $i = 0; $i < 10; $i++) { say $i }
    ===SORRY!===
    Word 'loop' interpreted as 'loop()' function call; please use whitespace around the parens
    at <unknown file>:1
Easily the nicest error reporting I've seen in a compiler.
Re:Differences Between Perl 5 and Perl 6 by cytzol on Wednesday October 07, 2015 @10:52AM (#10346355)
Any Perl 6 code will have to include a `use v6;` instruction at the very top of the file, so there's no chance of Perl 5 code being confused for it. Is this what you mean?

EDIT: this was completely wrong, see below.

Re:Differences Between Perl 5 and Perl 6 by colomon on Wednesday October 07, 2015 @11:09AM (#10346462)
`use v6;` is not mandatory in Rakudo. Off the top of my head, I don't think it's mandatory in theory in Perl 6, either. However, it is widely used to mark Perl 6 code, because it gives you a nice clean error message if you accidentally try running it in Perl 5.
Re:Differences Between Perl 5 and Perl 6 by cytzol on Wednesday October 07, 2015 @12:48PM (#10347108)
Oh! I could have sworn it was necessary. My bad.
Re:Differences Between Perl 5 and Perl 6 by perlgeek on Wednesday October 07, 2015 @01:08PM (#10347283)
You should declare the version of your code. 'use v6;' for Perl 6 code (more specific versions will come up soon), and "use 5.014" for Perl 5.14, for example.

This will give good error messages when trying to run your code with the wrong compiler.