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

Re: New defined-match operator

Thread Previous | Thread Next
From:
Richard Leach
Date:
February 22, 2019 15:21
Subject:
Re: New defined-match operator
Message ID:
CADWSe2d6qX=SeCyoiKWU6=fDk+b7m3h0FAC=O6s-JTTZfnL+9Q@mail.gmail.com
On Fri, Feb 22, 2019 at 6:33 AM Aristotle Pagaltzis <pagaltzis@gmx.de> wrote:
> * Richard Leach <rich+perl@hyphen-dash-hyphen.info> [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. ;-)

$foo->bar->baz->&&+->quux
$foo->bar->baz->&&.->quux


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


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