Re: [PHP-DEV] Feedback for nullc Idea

2025-03-25 Thread Robert Chapin
On 3/25/2025 4:11 PM, Rowan Tommins [IMSoP] wrote: Writing coalesce($foo, 0) or ($foo ?? 0) is a small cost when writing the code to save cost every time anyone reads it. I see, part of the concern is just avoiding implicit type coercion.  Yes, that would be an understandable reason to requir

Re: [PHP-DEV] Feedback for nullc Idea

2025-03-25 Thread Robert Chapin
wrong choice. I don't know if I'd go as far as banning a single-argument coalesce, but I would definitely discourage its use. The feedback and the thoughtful perspective on user mistakes are helpful.  Thank you again. - Robert Chapin

Re: [PHP-DEV] Feedback for nullc Idea

2025-03-24 Thread Robert Chapin
On 3/23/2025 11:10 AM, Larry Garfield wrote: I'm not sure it justifies a new pseudo-function language construct. Fair enough.  Thank you for the feedback. On 3/23/2025 2:37 PM, Rowan Tommins [IMSoP] wrote: It's telling that all your examples with ?? put a value other than null on the right-ha

[PHP-DEV] Feedback for nullc Idea

2025-03-23 Thread Robert Chapin
($var ?? null) with mandatory extra parentheses.  A functional expression could make this less prone to mistakes.  It would also avoid concerns with alternatives such as unary operators. Any feedback on this idea would be appreciated. - Robert Chapin

[PHP-DEV] Feature: Null Coalescing Variable Handling Construct

2025-03-18 Thread Robert Chapin
Nz.  What we can do with an expression like nullc($test) === 'on' should be compatible with other existing operators and is more elegant than operators-in-parentheses or any multi-line statements.  This would also resolve the problem of not being able to do the same in a user function. Further reading: https://wiki.php.net/rfc/unary_null_coalescing_operator - Robert Chapin