Re: [PHP-DEV] Discussion - Anti-null coercion

2023-10-30 Thread Larry Garfield
On Mon, Oct 30, 2023, at 11:17 AM, Ilija Tovilo wrote: > Hi Robert > > On Sun, Oct 29, 2023 at 7:31 PM Robert Landers > wrote: >> >> Hello Internals, >> >> We currently have a null coercion operator: ??, but we lack an >> anti-null coercion operator. >> ... >> fn() => >> ($_SERVER['HTTP_X_MY_HE

Re: [PHP-DEV] Discussion - Anti-null coercion

2023-10-30 Thread Ilija Tovilo
Hi Robert On Sun, Oct 29, 2023 at 7:31 PM Robert Landers wrote: > > Hello Internals, > > We currently have a null coercion operator: ??, but we lack an > anti-null coercion operator. > ... > fn() => > ($_SERVER['HTTP_X_MY_HEADER'] ?? null) > ? md5($_SERVER['HTTP_X_MY_HEADER']) > : null; > .

Re: [PHP-DEV] Discussion - Anti-null coercion

2023-10-29 Thread Sergii Shymko
On Oct 29, 2023, at 3:23 PM, Robert Landers mailto:landers.rob...@gmail.com>> wrote: Because falsy is different than null/non-existent. The closest equivalent is "array_key_exists" (instead of empty/isset) but this proposal isn't just applicable to arrays. I run into this pattern of "if not null

Re: [PHP-DEV] Discussion - Anti-null coercion

2023-10-29 Thread Robert Landers
On Sun, Oct 29, 2023 at 8:53 PM Sergii Shymko wrote: > > > > On Oct 29, 2023, at 1:31 PM, Robert Landers wrote: > > Hello Internals, > > We currently have a null coercion operator: ??, but we lack an > anti-null coercion operator. > > For example, if I wanted to operate on a header, if-and-only-i

Re: [PHP-DEV] Discussion - Anti-null coercion

2023-10-29 Thread Fabio Carpi
Following the php logic, maybe !?? From: Sergii Shymko Sent: Sunday, October 29, 2023 4:53:12 PM To: Robert Landers Cc: internals Subject: Re: [PHP-DEV] Discussion - Anti-null coercion On Oct 29, 2023, at 1:31 PM, Robert Landers mailto:landers.rob

Re: [PHP-DEV] Discussion - Anti-null coercion

2023-10-29 Thread Sergii Shymko
On Oct 29, 2023, at 1:31 PM, Robert Landers mailto:landers.rob...@gmail.com>> wrote: Hello Internals, We currently have a null coercion operator: ??, but we lack an anti-null coercion operator. For example, if I wanted to operate on a header, if-and-only-if it exists, I'd have to write someth

[PHP-DEV] Discussion - Anti-null coercion

2023-10-29 Thread Robert Landers
Hello Internals, We currently have a null coercion operator: ??, but we lack an anti-null coercion operator. For example, if I wanted to operate on a header, if-and-only-if it exists, I'd have to write something like this one-liner: fn() => ($_SERVER['HTTP_X_MY_HEADER'] ?? null) ? md5($_SERV