Re: [RFC] Default expression

From: Date: Mon, 26 Aug 2024 10:23:02 +0000
Subject: Re: [RFC] Default expression
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 26/08/2024 11:11, Andreas Leathley wrote:
On 26.08.24 11:26, Bilge wrote:
I would like to fix this if possible, because I think this should be valid, with emphasis on /if possible/, because it may be prohibitively complex. Will update later.
That would be a way to fix it, to basically make isset(default) a possible check if there is no default, similar to an undefined variable check. It would also recognize a default value of null as not set in the same way, so one could not differentiate between null and not defined, but that is in line with the language in general.
It would not be possible to write isset(default) because isset() does not operate on expressions. Similarly, it would not be possible to write default === null ? ... : ... because you would receive the same error as above. If we special-case null coalesce then it will literally only be possible to check with null coalesce. As for feasibility, I definitely believe it is feasible. Though some may argue whether it's worth the trouble for this edge case, I would still like to implement it. Cheers, Bilge

Thread (101 messages)

« previous php.internals (#125261) next »