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

Re: Capture Object: why no verb?

Thread Previous
From:
Audrey Tang
Date:
April 22, 2006 17:09
Subject:
Re: Capture Object: why no verb?
Message ID:
444AC5AC.5060906@audreyt.org
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. :)

Audrey


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About