Rakudo: Can’t override !~, =~, >>, <<

Created on 24 Oct 2017  ·  4Comments  ·  Source: rakudo/rakudo

How to reproduce

sub infix:<!~> { say @_ }; 3 !~ 4

Expected behavior

Prints [3 4].

Actual behavior

Exits with the following error: Unsupported use of !~ to do negated pattern matching; in Perl 6 please use !~~.

This also happens with =~, <<, >>, and possibly others.

Version information

This is Rakudo version 2017.09 built on MoarVM version 2017.09.1
implementing Perl 6.c.

operators

Most helpful comment

There's a bunch more ops and some things that are perfectly fine Rakudo code, but it gets complained like I'm a $language programmer who made a mistake:

$ perl6 -e '{ $^A }(42)'
===SORRY!=== Error while compiling -e
Unsupported use of $^A variable; in Perl 6 please use Form module
at -e:1
------> { $^A⏏ }(42)
$ perl6 -e '$/ = "x"'
===SORRY!=== Error while compiling -e
Unsupported use of $/ variable; in Perl 6 please use the filehandle's .nl-in attribute
at -e:1
------> $/⏏ = "x"
$ perl6 -e 'my $n = new class {}:'
===SORRY!=== Error while compiling -e
Unsupported use of C++ constructor syntax; in Perl 6 please use method call syntax
at -e:1
------> my $n = new class ⏏{}:

All these things are really annoying because they introduce conditions where normally-valid code is arbitrarily made invalid just because it's some construct in some language. The last one is especially annoying because I haven't written a single line of C++ code in my life. IMO all these errors should be disableable with a pragma, or better yet disabled by default and only enabled with some pragma; e.g. use beginner::helpers; Some argue for more verbose errors and IMO the extended errors could be stuffed under the same pragma.

All 4 comments

There's a bunch more ops and some things that are perfectly fine Rakudo code, but it gets complained like I'm a $language programmer who made a mistake:

$ perl6 -e '{ $^A }(42)'
===SORRY!=== Error while compiling -e
Unsupported use of $^A variable; in Perl 6 please use Form module
at -e:1
------> { $^A⏏ }(42)
$ perl6 -e '$/ = "x"'
===SORRY!=== Error while compiling -e
Unsupported use of $/ variable; in Perl 6 please use the filehandle's .nl-in attribute
at -e:1
------> $/⏏ = "x"
$ perl6 -e 'my $n = new class {}:'
===SORRY!=== Error while compiling -e
Unsupported use of C++ constructor syntax; in Perl 6 please use method call syntax
at -e:1
------> my $n = new class ⏏{}:

All these things are really annoying because they introduce conditions where normally-valid code is arbitrarily made invalid just because it's some construct in some language. The last one is especially annoying because I haven't written a single line of C++ code in my life. IMO all these errors should be disableable with a pragma, or better yet disabled by default and only enabled with some pragma; e.g. use beginner::helpers; Some argue for more verbose errors and IMO the extended errors could be stuffed under the same pragma.

Wondering how Perl 6 implements user-defined ops ( >_<

The magic happens here: https://github.com/rakudo/rakudo/blob/e9351cbaa961c4d1e4ef8b4cb52418d55766a8d6/src/Perl6/Grammar.nqp#L4804-L5036

Same as how'd you define a slang: you just mix in a role into grammar and actions

This is still an issue in the latest version. Is it an LTA error message? Or is it a bug?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alabamenhu picture alabamenhu  ·  5Comments

codesections picture codesections  ·  3Comments

AlexDaniel picture AlexDaniel  ·  3Comments

raiph picture raiph  ·  3Comments

zoffixznet picture zoffixznet  ·  4Comments