On Fri, Jan 24, 2014 at 11:20 AM, Philip Sturgeon <[email protected]>wrote:
> 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
> it was.
>
> 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:
>
> function(Spanner[] $spanner)
>
> 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:
>
> function(array<Spanner> $spanner)
> $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
>
Or you could finish up the "array of" proposal and put that to a vote.
If accepted, then A) or C) applies. If not accepted, then B) or D) applies
:)
>
> Nothing really binding here, its more of a survey than a vote, but it
> should help with the next steps.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
--
Tjerk