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

Re: postfix dereference syntax

Thread Previous | Thread Next
Nicholas Clark
July 2, 2013 11:48
Re: postfix dereference syntax
Message ID:
On Tue, Jul 02, 2013 at 01:41:20PM +0200, Rafael Garcia-Suarez wrote:
> On 27 June 2013 03:59, Ricardo Signes <> 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->@* = @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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About