Re: [RFC] Short syntax for anonymous functions
| From: | Marcello Duarte | Date: | Tue, 19 Feb 2013 17:45:20 +0000 |
| Subject: | Re: [RFC] Short syntax for anonymous functions | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-65976@lists.php.net to get a copy of this message | ||
On 19 Feb 2013, at 17:32, Leigh wrote:
>
> On 19 February 2013 16:46, Marcello Duarte <mduarte@inviqa.com> wrote:
> I find that more and more my developers have to learn ruby just to be able to work in our
> projects. We are one of the largest PHP shops in Europe and even the proprietary tools we are
> writing for DevOps stuff we are writing in Ruby. This small syntax arrangement would make it
> possible to write DSLs in PHP. The result is that I can have my PHP developers focusing on one
> language only and get the job done. The problem of the web is a bit more complex now, if you look on
> all you need to develop and deploy a large PHP application.
>
> That is one of the choices you made for your projects. You looked at what was available, and
> decided that Ruby was the best choice for the task at hand.
>
> While I agree it's unfortunate that your developers to have to waste their time learning
> Ruby, when they could be doing more productive things, that doesn't mean it's a good idea
> to try and retrofit some evil syntax into PHP "just for you", no matter how large an
> organisation you are.
I am curious: "evil syntax"? I am not attached to the syntax I have described. I am open
to discuss the syntax. It would be good with using the callable as last argument converted into a
block for DSLs. I don't think this is evil, but I don't want to fall into a personal taste
debate. I want something I can use.
And "just for you" is also inaccurate. You will find that the technologies I've been
referring to are becoming the tools you will use for DevOps, etc... tasks. Do you guys listen to
people outside of internals? It would be good to have a feedback mechanism that actually involve PHP
developers in real world projects. I take that if you are coding with other languages like C, all
the time, that you may loose contact with the way things are done.
> By the way, PHP is open source, feel free to make the parser do whatever you want.
>
>
>
> On 19 February 2013 16:40, Levi Morrison <morrison.levi@gmail.com> wrote:
> > Say we agree on the syntax above
> >> ($n) |$m| => $m * $n;
> > What happens when my one liner function needs to do one more operation
> > like checking the value of $n before multiplication?
>
> As I stated before suggesting the syntax: It's only meant for a single
> expression. It's purposefully NOT intended to cover multiple
> expressions. In that case the current (verbose) syntax is better for
> all criteria I care about. Additionally, neither Python nor Dart
> allows multiple expressions in their short-syntax functions.
>
> I prefer this. In this case (imho), a simplified syntax *should* go hand in hand with
> simplified functionality. If PHP is to adopt such a syntax I'd much prefer it takes the single
> expression approach. This does achieve the goals of easy readability and maintenance because you
> know the expression is bound by certain limitations.
>
--
Marcello Duarte
Head of Training
Inviqa
enterprise open source
e-mail: marcello@inviqa.com
mobile: +44 78 3316 8193
phone: +44 20 3179 9555
twitter: @_md @Inviqa
inviqa.com
Disclaimer
This email and any attachments may be confidential and are intended solely for the use of the
addressee. Any views or opinions expressed are those of the author and may not represent those of
Inviqa. If you are not the intended recipient of this email, you must neither take any action based
upon its contents, nor copy or show it to anyone. Please contact the sender if you believe you have
received this email in error.