Re: Introducing "Array Of" RFC

From: Date: Mon, 20 Jan 2014 22:39:22 +0000
Subject: Re: Introducing "Array Of" RFC
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Mon, Jan 20, 2014 at 5:00 PM, Andrey Andreev <[email protected]> wrote:
> Please excuse my lack of knowledge, but if I understand this correctly,
> this is how generics would work ... using arrays, ignore the syntax and
> details such as child classes, interfaces, etc.:
>
>    $fruits = Array<Fruit>; - declare that $fruits is an array that can only
> contain instances of class Fruit
>    function eat(Array<Fruit> $apples) - function eat() will only accept
> arrays that are declared in the same way as $fruits above
>
> If that is so, then I deffinately see how this RFC is similar to generics
> and how generics would give us higher performance. But I also see how it is
> different and how it serves for another (yet indeed similar) purpose.
>
> I wouldn't rule out either feature, but if that is what you people want,
> why don't you vote on:
>
>     a) array of; b) generics; c) both
>
> and be done with it. I surely do understand why Phil Sturgeon got so heated
> about the discussion going nowhere - at least 3 separate topics are being
> discussed here and everybody has an opinion on all of them separately. This
> isn't productive.

The conversation certainly escalated, but not through my doing. I
didn't say the conversation was going nowhere, I said much of it was
not discussing relevant points.

This was down to confusion on some points, only one of which was
generics. There are two things being discussed as one by many, which
is causing confusion for me and probably for others too.

1. Generics, instead of Array Of
2. Generics syntax for Array Of

With some people suggesting generics (not Sara) and some suggesting
just taking the syntax and using it for array of instead to add "weak
generics kinda" then we are crossing threads a little.

A vote would certainly help to work out which way people would like to go.

Some bullet points.

Generics are fine.
Generics later are fine.
Generics now would require a big recode, so that would be PHP 6 - not now.
Array of is simple, and could be done instead.
Array of and generics can both live in peace.
Both could use the same syntax - and we can talk about that, but that
can potentially confuse the user. Discussion on that is fine.

As long as we are clear about what is being discussed and proposed,
because there are a lot of routes:

1. Array of as is, no generics (for now...?)
2. Array of and generics, different syntax
3. Array of and generics, same syntax
4. No array of, let Generics do all of the work

If 4 is picked then it wont be done until a major version. 2 or 3
would need more discussion and delay things a bunch, 1 would get
things going.

I don't want to stifle discussion, but you can see why it would be
beneficial to avoid a contentious subject which is not completely the
same thing.


Thread (73 messages)

« previous php.internals (#71368) next »