Why can't I call "gist" on "while"? (Perl 6)

I can call the method gistfor the inline function say:

&say.gist
sub say (| is raw) { #`(Sub|54790064) ... }

Why can't I call giston while?

&while.gist
===SORRY!=== Error while compiling <unknown file>
Undeclared routine:
    while used at line 1

Obviously, it is whilenot a "subroutine", but it saydoes. But I thought all the Perl 6 built-in modules were really functions that we could override.

+4
source share
1 answer

I thought that all the Perl 6 plugins were really functions that we could override.

whileIt is not a subroutine or macro, but part of the syntax defined in the Perl6 grammar .

, , .

- , , ( %*LANG, , ).

froop.pm6:

use nqp;

sub EXPORT {
    nqp::bindkey(%*LANG, 'MAIN', nqp::atkey(%*LANG, 'MAIN').^mixin(role {
        rule statement_control:sym<while> {
            [$<sym>=froop{
                $/.hash<sym>.^mixin: role {
                    method Str { 'while' }
                }
            }|$<sym>=until]<.kok> {}
            <xblock>
        }
    }));

    once Map.new
}

while ( ) froop,

use froop;
my $i = 0;
froop $i < 5 { say $i++ }
+6

Source: https://habr.com/ru/post/1618375/


All Articles