Re: [RFC] Partial Function Application, take 2
| From: | Guilliam Xavier | Date: | Thu, 10 Jun 2021 18:35:39 +0000 |
| Subject: | Re: [RFC] Partial Function Application, take 2 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114823@lists.php.net to get a copy of this message | ||
On Thu, Jun 10, 2021 at 7:32 PM Guilliam Xavier <guilliam.xavier@gmail.com>
wrote:
>
> Since
$null?->whatever(1, 'a') currently always
> returns null without
> error, shouldn't $null?->whatever(?, 'a')
> return a closure (with a
> signature built from the placeholders only) that will return null when
> called (i.e. equivalent to fn (mixed $arg1) => null here)?
>
Ah, we can also see $foo?->bar(?) as simply "desugaring" to `$foo ===
null ? null : $foo->bar(?)`, so the current behavior makes sense too (and
maybe even "more")... I guess I was confused to get a "null-implying
error" despite using a "null-safe" call syntax :s (There's also the
possibility of not supporting it, but I guess that would be a lose-lose...)
--
Guilliam Xavier