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

Re: postfix dereference syntax

Thread Previous | Thread Next
From:
Ricardo Signes
Date:
July 2, 2013 14:29
Subject:
Re: postfix dereference syntax
Message ID:
20130702142850.GA10224@cancer.codesimply.com
* Rafael Garcia-Suarez <rgs@consttype.org> [2013-07-02T07:41:20]
> Also $href->%* I suppose.

Yeah.  And ->&* and ->** (!?)

> Can we talk about failure modes a bit?

Please!

> 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?

I brought up that operator some time ago, and basically said something like
this:

There were a bunch of edge cases when it first came up, and it wasn't clear how
the patch we had would behave, or how it should behave.  I was happy to pursue
the patch if we could show that it was going to make sense, and I thought the
most useful way to do it was to get the patch applying cleanly on blead to see
how it *did* behave.  Nobody stepped up to do that.

I think that *if it can work sanely* a ?-> operator, it is a force multiplier
for this syntax.  If we can't, I think this syntax still has value.  In other
words: I think they have value independent of each other, but even more
together.  This, to me, is a good sign for both. :)

> $foo and @foo are interpolated in strings, but not %foo. I suppose
> ->%* would not either? or maybe just exclude those constructs from
> interpolation whatsoever?

Yeah, we'd only interpolate, at most, ->$* and ->@*.  If we want a way to
stringize hashes, interpolating it, I think, will belong under a future
proposal.

-- 
rjbs

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