Guards are now ready for discussion (was: Nov 18 notes)

Peter van der Zee ecma at qfox.nl
Mon Nov 22 00:37:12 PST 2010


On Mon, Nov 22, 2010 at 6:54 AM, Brendan Eich <brendan at mozilla.com> wrote:

>
> 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?
>

I wouldn't want to introduce forced parens for the sake of disambiguation
for the coder. I'd rather go with ::, # or @ ...

Actually, for object literal I'd go for an equal sign (=), but that
obviously won't fix var declarations where the colon is fine.

Can't the guards proposal be applied to function parameters as well? Or am I
stepping on land mines there? :) It seems like the same logic could be
applied. In that case the equal sign is maybe even more preferable.

- peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20101122/bc9d02aa/attachment.html>


More information about the es-discuss mailing list