develooper Front page | perl.perl5.porters | Postings from July 2013

Re: postfix dereference syntax

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
July 2, 2013 11:48
Subject:
Re: postfix dereference syntax
Message ID:
20130702114757.GH3729@plum.flirble.org
On Tue, Jul 02, 2013 at 01:41:20PM +0200, Rafael Garcia-Suarez wrote:
> On 27 June 2013 03:59, Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:

> Also $href->%* I suppose.
> Can we talk about failure modes a bit?
> A common idiom is to write @{ $foo || [] } in case $foo might be undefined.
> Do you remember the conditional-dereference operator that was
> bikeshedded to oblivion? ($foo?->bar() was one of the proposed
> syntaxes). Can we have this, plus ->@*, plus ?->@* that would expand
> to an empty list if its argument is undef?

Ultimately it wasn't bikeshedded to oblivion.

rjbs attempted to restart things, asking questions about how it was supposed
to work, independent of its spelling, in certain unconsidered situations,
such as LVALUE context.

No-one answered.

And that question is actually relevant. What would this do for undefined
$foo?

    $foo->@* = @bar;
    @bar = $foo->@*;


Presumably for what you're suggesting, in LVALUE context, $foo autovifies.
In RVALUE context it does not (but does not error either)

Nicholas Clark

Thread Previous | Thread Next


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