![]() | |
#21
| |||
| |||
|
|
There is no need to propose any automatic insertion of quotes into the source text (or token stream) in order to account for the behaviour seen. And indeed such insertions would be contrary to the behaviour observed. For example:- var x = { x-y:5 }; - is a syntax error but:- var x = { 'x-y':5 }; - is not. The first being a mathematical expression in a context that only allows for Identifiers, string literals and numeric literals, while the second is a numeric literal. ^^^^^^^ |
#22
| |||||||||||
| |||||||||||
|
|
John G Harris wrote: The man who invented the language said it must be like that. Get used to it. If you can't, find another language. I wouldn't put the strict equality sign between what the Man did and what others (ECMA freelancers) managed to write about it. |
|
Say it was obvious for the Man that in case (function f() { })() function f being created and added to the namespace. It was so for him, for NN2.x-4.x, |
|
for Eric Lipper porting it to IE. |
|
Only much later during the "hand-pointer" opposition stage some read out an alternative meaning from ECMA to make IE wrong in yet another small but pleasurable point. |
|
On the topic and if you manage to fight over the regular "get VK!" instincts than you see that: { a: "a", b: "b" } is interpreted as a block with a and b label literals. |
|
{ a: "a", "b": "b" } is interpreted as a block with a and b label literals where b is illegal as we cannot use string value instead of literal so syntax error. |
|
var obj = { a: "a", "b": "b" } creates the necessary interpretation context so the right part is treated as an object constructor and the automatic quoting gets on, so we may quote the keys, do not quote them or do quote them zebra-style or whatever. |
|
Even if the very first key is not quoted, it is still interpreted as key string value, because the "interpretation decision" is being made before that. |
|
var obj = { a: "a", "default": "b" } absolutely the same as before, the "interpretation decision" is being made before entering so it is already decided that it is an object constructor and not a block of statements, so it is irrelevant that the first key is not quoted: the quotes will be added automatically. var obj = { a: "a", default: "b" } the "interpretation decision" is being made before entering so it is already decided that it is an object constructor and not a block of statements, so it is irrelevant that the first key is not quoted: the quotes will be added automatically; THEN the system meets [default] chars sequence which corresponds to one of reserved words in the parser list AND it changes its own previous decision: |
|
now no, it is not a constructor but a block of statements with the second one preceded by an illegal label literal. |
|
Some might find it very logical. I am definitely not in that club. |
#23
| |||
| |||
|
|
Richard Cornford wrote: I find it humorous that your profile in Google groups quotes Ockham's Raiser in Latin, as I cannot think of any better demonstration of spectacularly missing the point. Here we have a case where the simpler explanation certainly is the better explanation. "Effective Monday Nov.26 ... all object key strings to be placed in single quotes with internal single quotes escaped ... [the punishment stuff is irrelevant]" |
|
Now compare this and the full production description with possible branching from your post. This is exactly what Occam's Raiser is about, in my humble interpretation of course ![]() |
|
For the Fx (ab)normality I am going to ask out of curiosity at mozilla.dev.tech.js-engine |
#24
| |||
| |||
|
|
I find it humorous that your profile in Google groups quotes Ockham's Raiser in Latin, as I cannot think of any better demonstration of spectacularly missing the point. Here we have a case where the simpler explanation certainly is the better explanation. |

#25
| |||
| |||
|
|
Richard Cornford wrote: I find it humorous that your profile in Google groups quotes Ockham's Raiser in Latin, as I cannot think of any better demonstration of spectacularly missing the point. Here we have a case where the simpler explanation certainly is the better explanation. "Effective Monday Nov.26 ... |
|
all object key strings to be placed in single quotes with internal single quotes escaped ... [the punishment stuff is irrelevant]" Now compare this and the full production description with possible branching from your post. This is exactly what Occam's Raiser is about, in my humble interpretation of course ![]() |
|
For the Fx (ab)normality I am going to ask out of curiosity at mozilla.dev.tech.js-engine |
#26
| |||
| |||
|
|
Richard Cornford wrote: There is no need to propose any automatic insertion of quotes into the source text (or token stream) in order to account for the behaviour seen. And indeed such insertions would be contrary to the behaviour observed. For example:- var x = { x-y:5 }; - is a syntax error but:- var x = { 'x-y':5 }; - is not. The first being a mathematical expression in a context that only allows for Identifiers, string literals and numeric literals, while the second is a numeric literal. ^^^^^^^ Do you mean "string"? |
|
As for the rest, thank you for your patient explanations. One can only hope something of it gets through to him. |
#27
| |||
| |||
|
|
Richard Cornford wrote: For the Fx (ab)normality I am going to ask out of curiosity at mozilla.dev.tech.js-engine Richard Cornford wrote: On your record of such promises, I will not be holding my breath. |
#28
| |||||||
| |||||||
|
|
On the topic and if you manage to fight over the regular "get VK!" instincts than you see that: { a: "a", b: "b" } is interpreted as a block with a and b label literals. |
|
{ a: "a", "b": "b" } is interpreted as a block with a and b label literals where b is illegal as we cannot use string value instead of literal so syntax error. |
|
var obj = { a: "a", "b": "b" } creates the necessary interpretation context so the right part is treated as an object constructor and the automatic quoting gets on, |
|
so we may quote the keys, |
|
do not quote them or do quote them zebra-style or whatever. Even if the very first key is not quoted, it is still interpreted as key string value, because the "interpretation decision" is being made before that. |
|
var obj = { a: "a", "default": "b" } absolutely the same as before, the "interpretation decision" is being made before entering so it is already decided that it is an object constructor and not a block of statements, so it is irrelevant that the first key is not quoted: the quotes will be added automatically. |
|
var obj = { a: "a", default: "b" } the "interpretation decision" is being made before entering so it is already decided that it is an object constructor and not a block of statements, so it is irrelevant that the first key is not quoted: the quotes will be added automatically; THEN the system meets [default] chars sequence which corresponds to one of reserved words in the parser list AND it changes its own previous decision: now no, it is not a constructor but a block of statements with the second one preceded by an illegal label literal. |
#29
| |||
| |||
|
|
We may use string literals as keys. The difference between *foo: 42 and *"foo": 42 isn't that we quote anything, but that one is an identifier and the other is a string literal. Completely different syntactic categories, both valid at this particular point of an object initializer. |
- then in case like
#30
| |||
| |||
|
|
Lasse Reichstein Nielsen wrote: We may use string literals as keys. The difference between *foo: 42 and *"foo": 42 isn't that we quote anything, but that one is an identifier and the other is a string literal. Completely different syntactic categories, both valid at this particular point of an object initializer. I think I am starting to see the mistake making by Richard and by you: or maybe and very probably not a mistake but some profound difference in the applied logic between of us, because - I agree in advance - my logic is too "special". If unquoted key is interpreted as identifier - in the identifier sense I am using for more than 10 years and to late to change I'm afraid : ( - then in case likevar a = 'foo'; var obj1 = {a : 'bar'} var obj2 = {'a': 'bar'} obj1 and obj2 have to have different properties: 'foo' in the first case, 'a' in the second. In the reality both of them are having the same property 'a' |
|
I am really sorry but an "identifier" that is not get identified is not an identifier, and the whole ECMA 262 wisdom may not override it in my (stupid, stubborning, whatever) head. |
![]() |
| Thread Tools | |
| Display Modes | |
| |