develooper Front page | perl.perl6.language | Postings from April 2006

Re: Capture Object: why no verb?

Thread Previous
Audrey Tang
April 22, 2006 17:09
Re: Capture Object: why no verb?
Message ID:
Dave Whipp wrote:
> Also, I'm a bit confused By the idea that the invocant is obtained by a
> scalar dereference, because I know that arrays and hashes can be
> invocants, too. E.g. @a.pop. So, If I do:
>   my $args = \(@a:);
>   my $b  = $$args;  # @a as a scalar
>   my @c  = @$args;  # empty list
>   my @d := $$args;  # bound to @a

That is totally correct. "Scalar" here really means "any one thing", any
Array is but one kind of one-thing.

> Is there any way that a deref can determine that the invocant stored in
> the capture was placed there using the '@' sigil? Perhpas this leads to
> the question of whether there is ever a reason for code to distinguish
> between @ invocants and $ invocants. I'm guessing that the answer must
> be "no".

No.  If you really want to flatten at list context the content of
invocant, then @$$args will do what you want, though it's a bit heavy. :)


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About