In recent discussions we were weighing up the options of array of and
generics came into conversation, brought forward from the Hack
language by Sara G.
I was wrong about one thing: Generics CAN have setup outside of the
type-hint, much like a collection, but it is not required. I thought
This means that array of could easily be considered "weak-generics"
and the two features can share the same syntax without confusion to
the user. A few of you said that, so sorry that I disagreed. ;)
Before we worry too much about that, the logical next question is:
Is there any interest in generics? If there is interest, then one
syntax would be preferable over the other.
With the existing proposed syntax for "array of", it looks like this:
Evolving that same syntax into generics would look something like this:
$tool = new Spanner;
$tool = new int;
That would be... less than ideal, but its nice and simple for the type hints.
Using the generics syntax for... generics:
$tool = array<Spanner>();
Obviously angle-brackets are a bit new, but that same syntax works for both.
These examples are provided to make a point, and the syntax is not
definite. The point here really is that If we care about generics,
then using generic-like syntax for this feature probably makes sense.
If we don't care about generics, then there is probably no point using
this more verbose syntax for simple "array of" type-hinting, but the
syntax could still easily change.
Can you lot vote A, B, C or D to show your interest?
A) I want Array Of, but not Generics
B) I want Generics, but not Array Of
C) I want both
D) I want neither
Nothing really binding here, its more of a survey than a vote, but it
should help with the next steps.
[PHP-INTERNALS] [PHP-DEV][VOTE] "Array Of" v Generics
- Rasmus Lerdorf: An RFC survey? This is not what this process is intended for. And these multi-option votes are rather useless. This feels like a waste of time to me. -Rasmus
- Will Fitch: I agree. I think this proposal isn't mature enough to initiate any type of voting. I'm not a fan of how this went from proposing "arrayof" to a comparison of generics. IMHO, if this is to proceed as a vote now, it should simply be for the proposed syntax/functionality Yes/No only. If generics are still being discussed, then discussions need to continue, and a vote is a bit farther down the road.
- Kristopher: I think both of you are missing the point that "RFC" is nowhere in the subject nor body of his message. He's just trying to further along the discussion of which route to go.