develooper Front page | perl.perl5.porters | Postings from February 2019

Re: New defined-match operator

Thread Previous | Thread Next
Richard Leach
February 22, 2019 15:21
Re: New defined-match operator
Message ID:
On Fri, Feb 22, 2019 at 6:33 AM Aristotle Pagaltzis <> wrote:
> * Richard Leach <> [2019-02-22 02:44]:
 > if($foo &&~ /bar/) seems cognitively easier.
> Dunno that it’s easier, but the proposal was for it to be testing
> definedness, not truthiness, so I do know it’s more misleading.

Agreed, it's not checking the same thing.

My concern with //~ was that it makes the defined-or operator pull
double duty as the defined-and operator.

> Also I’m sure &&~ already occurs in actual code since not only does
> it have some meaning, like //~ does, it’s even a very plausible one.
> > Horrible line noise follows:
> I agree. :-)
> > (if you assumed the && applied to all previous calls, then
> > $foo->bar->baz->&&->quux)
> And if you want it applied to all *following* calls instead…?
> And if only the middle call in the chain should be optional…?

Getting even worse, but you could give it modifiers. ;-)


More seriously, as well as checking for definedness, would there be
some use for checking for existence? e.g. short circuiting if a nested
hash structure doesn't have all the specified elements, rather than
autovivifying some and then warning about uninitialized values.

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