-
What is the motivation for the Zoe keyword constraint? Some of us (@ivanlei , ...) were discussing this in the context of... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@erights explained... I’ll start this with a true story of the hazard we’re trying to avoid before going into too much detail. JS has two main forms of property lookup: All such statically known property names built into JS begin either with a lowercase letter or an underscore. Widespread convention which we follow also names all such program internal property names with a lowercase letter. When we do have an expression such as Given that most programs mostly avoid computed property lookup for their own statically known property names, another place where normal JS programs use The main remaining utility of Instead, Zoe’s KeywordRecords (like all CopyRecords) inherit from JavaScript’s > y = JSON.parse('{"ToString": 8}')
> y + ''
'[object Object]'
> x = JSON.parse('{"toString": 8}')
> x + ''
Uncaught TypeError: Cannot convert object to primitive value Our keyword rules not only insist only on identifiers beginning with an upper case letter, they also prohibit the number-names including |
Beta Was this translation helpful? Give feedback.
@erights explained...
I’ll start this with a true story of the hazard we’re trying to avoid before going into too much detail.
At one time, if you wrote a Google doc consisting only of the string
__proto__
your document would hang.JS has two main forms of property lookup:
obj.name
andobj[expr]
, whereexpr
is expected to evaluate to a property name or array index. We can generally divide most property names into two categories: those statically known by the author of the program, and those determined by data entering the program from the outside, such as all incoming messages. For statically known property names, they are almost always used asobj.name
, where, for example, the type dep…