develooper Front page | perl.perl6.language | Postings from January 2009

Re: returning one or several values from a routine

Thread Previous
From:
Jon Lang
Date:
January 6, 2009 13:43
Subject:
Re: returning one or several values from a routine
Message ID:
ef30550b0901061342v2081ed75g813e74eba3ba7259@mail.gmail.com
TSa wrote:
> Jon Lang wrote:
>>   item($x) # Dwimmey use of item context.
>
> IIRC this is the same as $$x, right? Or does that
> extract the invocant slot without dwimmery?

Umm... good question.  This is a rather nasty paradox: on the one
hand, we want to be able to stack $, @, and % with capture objects in
analogy to Perl 5's references, which would indicate that they should
tie directly to the invocant, positional parameters, and named
parameters, respectively.  OTOH, the intuitive meaning for these
symbols would seem to be "item context", "list context", and "hash
context", respectively, which would argue for the dwimmery.

The question is which of these two sets of semantics should be
emphasized; once that's answered, we need to be sure to provide an
alternative syntax that gives us the other set.  IOW, which one of
these is "make common things easy", and which one is "make uncommon
things possible"?

>>   $x._ # the Capture object's invocant, as an item.
>
> How about $x.() here? That looks symmetric to the other
> postfix operators and should be regarded as a method
> dispatched on the invocant or some such.

Symmetric, but ugly.  I suggested the underscore because '.foo' is the
same as '$_.foo'; so you can think of the invocant of a capture object
as being roughly analogous to a topic.

-- 
Jonathan "Dataweaver" Lang

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