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

Re: Pre-RFC: Optional Chaining

Thread Previous | Thread Next
June 4, 2022 03:04
Re: Pre-RFC: Optional Chaining
Message ID:
On Fri, Jun 3, 2022 at 5:38 PM Ricardo Signes <>

> Having re-read the posts, I think there was a lot of work in the weeds,
> and the pre-RFC question sounds like "yes of course people would like
> something like this," and then we get to the actual RFC question.  But
> Breno's pre-RFC was basically an RFC and could be filed as such, then to be
> worked on until ready for someone to have a crack at implementing.

That's terrific, thank you all for considering this proposition!

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
Perfect, except I think it really should address the empty list case by
returning () (which becomes undef in scalar context) instead of always
returning plain undef:

   defined EXPR1 ? EXPR1->EXPR2 : ()

So we can also write:

    push @list, $item?->foo;   # does NOT add undef to @list when $item is
    @list = $arrayref?->@*;    # if $arrayref is undef, @list stays empty
and not (undef)

I think the objection (made by a few, including me) that we need to use
> "defined" (as I do in the snippet above) rather than "ref" as the test
> should be taken into account in any re-submission of the RFC.

I agree with the objection and I am very much ok with it using "defined"
instead of "ref", and volunteer to work on an updated version of the
original document, to be resubmitted as an exploratory RFC back to the
group or as a PR, at the PSC's discretion.


> But is there anything left to do but…
>    1. submit the RFC in an updated form
>    2. discuss whether it's ready to implement in that form
>    3. eventually say it's ready for implementing
> ?

I'd like to address some observations made before regarding the proposal,
but I'll do it in a separate email.


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