Re: An implementation of a short syntax for closures
| From: | Johannes Schlüter | Date: | Thu, 04 Aug 2011 11:39:35 +0000 |
| Subject: | Re: An implementation of a short syntax for closures | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-54350@lists.php.net to get a copy of this message | ||
On Thu, 2011-08-04 at 21:18 +1000, Ryan McCue wrote:
> Lazare Inepologlou wrote:
> > Thank you for your interest. This is just a proposal that I have tested and
> > works. Of course, the final syntax can be different. Syntax is always a
> > matter of taste :-)
>
> As much as I love the idea, I have to agree that using | doesn't really
> make sense here and actually makes the readability worse, IMO. However,
> I can't really think of a better operator. ( $x ) => $x + 1 for example
> would be ambiguous if used in an array definition, but is otherwise the
> best in terms of readability.
If you go there you can also allow more complex statements and re-use
symbols used to group statements, using a syntax like
( $x ) { $x + 1; }
Oh wait - now we've reached a point which was mentioned in this thread
already "allow to drop the function keyword".
Back when I proposed to drop "function" a key argument was that people
wanted an easy way to grep for function declarations. I accepted the
validity of that concern and think this might be a case here, too. The
difference of these few characters is not that much but the keyword
gives a clear guidance what's going on, else you might end up with a
long list of random characters next to each other ...
johannes