Re: [RFC] [Discussion] Operator functions
| From: | Marco Pivetta | Date: | Fri, 08 Sep 2017 22:45:58 +0000 |
| Subject: | Re: [RFC] [Discussion] Operator functions | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100476@lists.php.net to get a copy of this message | ||
On Fri, Sep 8, 2017 at 11:41 PM, Andrea Faulds <ajf@ajf.me> wrote:
> Hi everyone!
>
> Here's an RFC for a small, simple, self-contained feature with no
> backwards-compatibility breaks and which in fact doesn't even touch the
> language's syntax (it's 50%+1 eligible!) but which could make PHP a bit
> more expressive and consistent, especially with potential later features.
> It even has a test designed to impose minimal maintenance burden while
> testing a fairly large possibility space!
>
> Anyway, the RFC in question is this:
> https://wiki.php.net/rfc/opera
> tor_functions
>
> Please tell me what you think and suggest any potential improvements or
> anything you think might have been an omission.
>
> Thanks!
> --
>
This is bloody brilliant!
Stupid example, but:
function factorial(int $i) { return array_reduce(range(1, $i), "*", 1); }
I see great potential in this: moving away from operators as weird
syntactic sugar and in the direction of operators as functions (what they
actually are).
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/