On Jul 14, 2011, at 4:47 PM, Parrot Raiser wrote:
When a subroutine is invoked with an empty parameter list, as follows:
run_stuff();
sub run_stuff {
my ($parm) = @_;
say "Parameter is $parm";
}
@_[0] contains "Any()".
Should it?
Yes, but only because of the way you are inspecting it.
When run_stuff is called with no arguments, @_ is empty.
It does *not* contain an element with the value Any; it contains no
elements at all.
When you ask for the value of a specific (and non-existent) element of
the array,
you only see that the element has no defined value yet.
(The `Any` value in Perl 6 is like the `undef` value in Perl 5.)
The same will happen if you declared @foo, then asked for the value of
@foo[42].
perl -MData::Dumper -e 'sub look { print Dumper scalar(@_), \@_,
$_[0]; } look();'
$VAR1 = 0;
$VAR2 = [];
$VAR3 = undef;
perl6 -e 'sub look { .say for @_.elems, @_.perl, @_[0].perl; }; look();'
0
[]
Any
--
Hope this helps,
Bruce Gray (Util)