On 20/01/14 18:43, Philip Sturgeon wrote:
Syntax
---------
There have been a lot of people suggesting various types of syntax. As
Joe said, using generics syntax for not generics would be a travesty,
and an overcomplication of what should be a simple feature.
Using generics-like syntax is more consistent with what we have already, though. Having "Array" for an array yet "Bar[]" for an Array of bar is confusing, especially since you'd then also logically have "Array[]". Why?
Using the generics syntax does not require adding generics. It simply allows a better syntax which is consistent with the existing syntax. I'd much rather have "Array", "Array<Bar>" and "Array<Array>" here than "Array", "Bar[]" and "Array[]".
It's also compatible with HHVM, which is a plus.
I don't agree that this would be "an overcomplication of what should be a simple feature.". It would not at all. This syntax is simpler, more consistent and more logical than that originally proposed.
For those who hate OOP, array of would be a lovely way to ask for an
array of callables. Trying to make generics happen is a great way to
force not only new syntax, but a brand new OOP paradigm that will be
new for EVERYONE, so ignoring that syntax and letting our functional
and OOP folks have a nice thing shouldn't be considered a negative.
Again, generics-esque syntax doesn't mean adding generics.
It also means that, if generics were added in future, we could use generics here - and they'd implement the same functionality in a better way. :)
This is something I hope we can all agree on. It is by no means
confusing, but I would be happy to run a poll and get NetTuts to tweet
it, to see if the average user is confused by this syntax. I've
tweeted about it and had 1 out of 50ish replies saying they weren't
sure. The confusion of 2% is something that can easily be fixed with
documentation and time.
Again, I'll be blogging about 5.6 features on NetTuts so those same
beginner level users will know all about it, and our documentation
will explain it for everyone else, meaning a 2% sub-section of users
will be EASY to fix.
Why should we use a poll of some random tutorial site? This is a developer mailing list!
--
Andrea Faulds
http://ajf.me/