On Nov 21, 2010, at 7:52 PM, Mark S. Miller wrote: > On Sun, Nov 21, 2010 at 7:48 PM, Brendan Eich <bren...@mozilla.com> wrote: >> The reason I chose "::" over ":" is not for a love of "::". Alternative >> suggestions appreciated! However, I avoided ":" so that we could guard >> properties within object literals >> <http://wiki.ecmascript.org/doku.php?id=strawman:guards#guarding_properties>. >> I don't see a way to use ":" for that without confusion. The ES4 solution >> -- that one can only annotate an object literal as a whole but not its >> individual properties -- always seemed unpleasant. > > :: is strictly less pleasant, and really kind of "taken" due to the > precedents I cited. The "less pleasant" point is the big one IMHO. > > Can we find something better than "::" that doesn't conflict with the ":" in > the object literal syntax? As I said, I have no love for "::".
Annotating property names in object initialisers is a relatively infrequent use-case -- a hard case that should not impose double the number of colons on all annotated declarations (formal parameters, let/const/var, function return types). The ML-ish solution, which is forward compatible, is to parenthesize: let typedObj = { (prop1:type1): value1, (prop2:type2): value2, ... }; The parentheses hurt too, but only this case. And it still may win to annotate the entire ObjectLiteral sometimes, which would avoid (or move to one common guard-type definition) the property-wise annotation overhead. Comments? /be _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss