Generics in JavaScript 2
Date : 2008 03 03 Category : Tech & DevelopmentFrancis Cheng continues on his walk through of ECMAScript Edition 4 features, this time discussing type parameters (read: generics in Java).
We could end up with code like this:
PLAIN TEXT JAVASCRIPT:function reprimand(list:List.<+Employee>) { ... }
var writingTeam:List.<techwriter> = new List.</techwriter><techwriter>();
reprimand(writingTeam); // no error if ECMAScript adopts this style of variance annotation
I have to admit to having a few shakes when I see this. I went through the Generics migration in Java land, and if I had a choice I would probably roll it back, or at least get erasure in there.
And the period before the angle brackets instead of just copying Java? Hmm. In general I don't like the angle brackets as they mess up when you mix with HTML. Now I am rambling.
Where would you like to see this go in a future JavaScript?