I'd also vote C.
The general response I've had from everyone I've spoken to about this
is along the lines of C, but opinion is extremely divided over whether
typed arrays should have a syntax that echoes generics or not. At
first I was firmly in the Foo[] camp but I have come to like the idea
of array<Foo>. In the context of PHP, with an absence of "proper"
arrays, they really have no semantic difference, and it makes sense to
make them syntactically analogous.
Thanks, Chris
On 24 January 2014 03:20, 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
>
> 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
>