5

In Perl 5, it's best to use

use strict;
use warnings;

to ask the compiler to complain about missing semicolons, undeclared variables, etc.

I have been informed by citizens of the Perl community here on SO that Perl 6 uses strict by default, and this seems after testing to be the case.

Semicolons aren't required for the last statement in a block, but if I extend the block later, I'll be chagrinned when my code doesn't work because it's the same block (and also I want semicolons everywhere because it's, like, consistent and stuff).

My assumption is that Perl 6 doesn't even look at semicolons for the last statement in a block, but I'm still curious: is there a way to make it stricter yet?

jjmerelo
  • 22,578
  • 8
  • 40
  • 86
cat
  • 3,888
  • 5
  • 32
  • 61
  • 4
    I don't think Perl 5 warns about missing semicolons at the end of a block either, at least not with just `use strict` and `use warnings`. – Jonathan Cast Jan 26 '16 at 22:40
  • 4
    You could create a slang that requires it. – Christopher Bottoms Jan 26 '16 at 23:59
  • 3
    "if I extend the block later, I'll be chagrinned when my code doesn't work ...". It almost certainly won't even compile if you omit the semi-colon. Perls embed a syntactic analog to [self-clocking](https://en.wikipedia.org/wiki/Self-clocking_signal) in their grammar. You get a compile time error ("Two terms in a row across lines (missing semicolon or comma?)"), accurately pinpointing the exact location of the problem, if you accidentally omit a semi-colon, in almost all cases. This is the main reason why having semi-colon separation of statements is better than not having them. – raiph Apr 19 '16 at 15:08

1 Answers1

4

Rather than enforce the extra semi-colon, Rakudo does try to give you a good error/hint if you do add to your block and forget to separate statements.

Typically I get "Two terms in a row across lines (missing semicolon or comma?)" when this happens.

awwaiid
  • 176
  • 1
  • 3