Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Introduce "use p5isms" pragma
When this pragma is activated in a scope, then the errors about using
Perl 5 constructs will *not* be thrown.  This does *not* do anything else.
So "defined" without any parameter will still not check $_: instead it
will just complain that calling defined without any parameters will never
work.  And *that* allows a module to export a "defined" sub that will check
$_ when called without any parameters.

I realize this is close to the 2018.05 release.  If it's too controversial
then please remove this before the release.
  • Loading branch information
lizmat committed May 17, 2018
1 parent b8318b8 commit 8ae82a5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
42 changes: 25 additions & 17 deletions src/Perl6/Grammar.nqp
Expand Up @@ -360,29 +360,37 @@ role STD {
# "when" arg assumes more things will become obsolete after Perl 6 comes out...
method obs($old, $new, $when = 'in Perl 6') {
$*W.throw(self.MATCH(), ['X', 'Obsolete'],
old => $old,
replacement => $new,
when => $when,
);
unless $*LANG.pragma('p5isms') {
$*W.throw(self.MATCH(), ['X', 'Obsolete'],
old => $old,
replacement => $new,
when => $when,
);
}
}
method obsvar($name, $identifier-name?) {
$*W.throw(self.MATCH(), ['X', 'Syntax', 'Perl5Var'],
:$name, :$identifier-name);
unless $*LANG.pragma('p5isms') {
$*W.throw(self.MATCH(), ['X', 'Syntax', 'Perl5Var'],
:$name, :$identifier-name);
}
}
method sorryobs($old, $new, $when = 'in Perl 6') {
$*W.throw(self.MATCH(), ['X', 'Obsolete'],
old => $old,
replacement => $new,
when => $when,
);
unless $*LANG.pragma('p5isms') {
$*W.throw(self.MATCH(), ['X', 'Obsolete'],
old => $old,
replacement => $new,
when => $when,
);
}
}
method worryobs($old, $new, $when = 'in Perl 6') {
self.typed_worry('X::Obsolete',
old => $old,
replacement => $new,
when => $when,
);
unless $*LANG.pragma('p5isms') {
self.typed_worry('X::Obsolete',
old => $old,
replacement => $new,
when => $when,
);
}
}
method dupprefix($prefixes) {
Expand Down
2 changes: 2 additions & 0 deletions src/Perl6/World.nqp
Expand Up @@ -933,6 +933,7 @@ class Perl6::World is HLL::World {
'strict', 1,
'trace', 1,
'worries', 1,
'p5isms', 1,
);

# pragmas without args that just set_pragma to true
Expand All @@ -950,6 +951,7 @@ class Perl6::World is HLL::World {
'nqp', 1,
'trace', 1,
'worries', 1,
'p5isms', 1,
);

# not yet implemented pragmas
Expand Down

0 comments on commit 8ae82a5

Please sign in to comment.