declarator anon

Documentation for declarator anon assembled from the following types:

language documentation Variables

From Variables

(Variables) declarator anon

The anon declarator prevents a symbol from getting installed in the lexical scope, the method table and everywhere else.

For example, you can use it to declare subroutines which know their own name, but still aren't installed in a scope:

my %operations =
    half   => anon sub half($x{ $x / 2 },
    square => anon sub square($x{ $x * $x },
    ;
say %operations<square>.name;       # square 
say %operations<square>(8);         # 64