object literal types
brendan at mozilla.com
Tue Feb 17 09:41:47 PST 2009
On Feb 17, 2009, at 5:07 AM, Michael Haufe wrote:
> David-Sarah Hopwood wrote:
>> "':' (not '=') is used to separate a property name from its value,
>> so it
>> can't also be used for type annotations."
Sharp variables (which I modeled after Common Lisp) are different
syntax -- their = sign comes *before* the object-type property value
or outermost object or array initialiser, and the = is preceded by the
sharp variable name. Also, you can't have any spaces between #n and =
(for non-negative integer n). There's really no comparison with the
syntax you sketched.
> which is what sparked my question.Is there some ambiguity on why
> this syntax reuse would be off the table?
Yes, there is an ambiguity. See the grammar:
PropertyName ':' AssignmentExpression
PropertyNameAndValueList ',' PropertyName ':' AssignmentExpression
More information about the Es-discuss