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

Re: postfix dereference syntax

Thread Previous | Thread Next
Ricardo Signes
July 2, 2013 14:29
Re: postfix dereference syntax
Message ID:
* Rafael Garcia-Suarez <> [2013-07-02T07:41:20]
> Also $href->%* I suppose.

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

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

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

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


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About