> I personally don’t see a huge use for this in my own work actually, I’m just 
> trying to make sure that something I will likely have to live with from 
> *other* developers isn’t impossible to read, that’s all. But I agree that 
> most people seem focussed on the actual syntax.

Well, I do. We use closures quite extensively at our workplace since we’ve 
started using the functional PHP library:
https://github.com/lstrojny/functional-php

Here’s a silly Swift vs. PHP example:

```Swift
let x = 4
let y = [1, 2, 3, 4]
    .map { $0 * x }
    .filter { $0 > x }
```

```PHP
$x = 4;
$y = [1, 2, 3, 4];
$y = map($y, function ($val) use ($x) { return $val * $x; });
$y = filter($y, function ($val) use ($x) { return $val > $x; });
```

Don’t you agree that the Swift example is much more readable?

I’d also like to say that this is a rather fair example.
The PHP code can get worse when using longer variable names, more captured 
variables and type hints.

> All I would ask is that one of the vote choices for syntax is to re-use the 
> existing function keyword.

Fair enough. The voting about syntax was only a suggestion though. Levi has 
never agreed to that :)

Cheers


On 4 Feb 2017, 17:26 +0100, Stephen Reay <php-li...@koalephant.com>, wrote:
> Hi Ilija,
>
> > On 4 Feb 2017, at 23:19, ilija.tov...@me.com wrote:
> >
> > Hey Stephen
> >
> > > You’re really starting to lose me now. You want types but don’t want to 
> > > define them, and you’re somehow mixing phpdoc into this.
> >
> > Because we use PHPDoc to provide type hints to the IDE where PHP doesn’t 
> > support them yet (variables and properties).
> >
> > > Currently PHP has zero support for Foo[] (or array<Foo> if you prefer) as 
> > > a type hint. In *theory* an IDE could use the calling scope’s context 
> > > (assuming the source of the array is purely local or from 
> > > arguments/return values that are typed) to infer types, but I haven’t 
> > > seen it, and I would likely still use type hints, to cover the case where 
> > > something changes elsewhere.
> >
> > That’s because you don’t trust it ;) You should be able to trust it.
> >
> > But anyway, that’s beside the point. Let’s get back to the RFC.
> >
> > > What were you saying about not everyone being the same?
> >
> > What I’m saying is that maybe it would make sense to vote for syntax, as 
> > this would make most people happy.
> > People seem to complain about that the most but agree with the general idea 
> > of the RFC.
> >
>
> I personally don’t see a huge use for this in my own work actually, I’m just 
> trying to make sure that something I will likely have to live with from 
> *other* developers isn’t impossible to read, that’s all. But I agree that 
> most people seem focussed on the actual syntax.
>
> All I would ask is that one of the vote choices for syntax is to re-use the 
> existing function keyword.
>
> Cheers
>
> Stephen
>

Reply via email to