develooper Front page | perl.perl5.porters | Postings from June 2022

Re: Pre-RFC: Optional Chaining

Thread Previous | Thread Next
From:
Salvador Fandiño
Date:
June 5, 2022 08:01
Subject:
Re: Pre-RFC: Optional Chaining
Message ID:
f783d625-0957-5e20-f0ac-1b99ab1c68cc@gmail.com
On 5/6/22 1:15, Oodler 577 via perl5-porters wrote:
> * breno <oainikusama@gmail.com> [2022-06-04 00:04:36 -0300]:
> 

>>
>> My comments on the PSC call this morning were mostly that I felt the most
>>> valuable simplification would be to provide an explanation of ?-> in terms
>>> of what it's equivalent to.  For example:
>>>
>>> EXPR1 ?-> EXPR2
>>>
>>> # is equivalent to
>>>
>>> defined EXPR1 ? EXPR1->EXPR2 : undef
>>>
>>> # with the caveat that EXPR1 is only evaluated once
> 
> I like this, but what distinction does "defined" or "truthy"
> hold with references?
> 
> It seems necessary for this to even be "true", the following
> conditions must hold:
> 
> * it's not undef
> * it's blessed
> * it "can" EXPR2


Don't forget that perl allows one to call methods on strings as in...

   $class = 'Foo';
   $class->new();

So, "?->" requiring a reference there would be inconsistent.




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