object literal types

Brendan Eich 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."
>
> Except in the case of JavaScript's non-standard Sharp Variables (https://developer.mozilla.org/En/Sharp_variables_in_JavaScript 
> ),

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:

PropertyNameAndValueList:
      PropertyName ':' AssignmentExpression
      PropertyNameAndValueList ',' PropertyName ':' AssignmentExpression

/be



More information about the Es-discuss mailing list