On Sat, Aug 29, 2020 at 9:05 PM ToddAndMargo via perl6-users
<perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:
And if you would not mind, what is the official name
of variables that begin with ":"
On 2020-08-30 00:43, Brad Gilbert wrote:
There are no variables that begin with :
There are variable declarations in signatures that begin with :
:$foo is exactly the same as :foo($foo)
sub bar ( :$foo ) {…}
sub bar ( :foo($foo) ){…}
:$foo in a signature is a shortcut for declaring a named argument :foo()
and a variable with the same base name $foo
:$foo also does the same thing as an argument
my $foo = 1;
bar( :$foo )
bar( :foo($foo) )
bar( foo => $foo )
Note that forms with : can be outside of the signature
bar( ) :$foo
bar( ) :foo($foo)
Follow up questions:
1) what is the exact name used to describe these critters?
2) is there a manual page on them?