L
Lasse Reichstein Nielsen
VK said:That's pretty much points to your regular problem when dealing with
JavaScript, and on a bigger scale - the common problem of many
regulars, getting the base of their wisdom from ECMA262 3rd.ed.
ECMA262 3rd.ed. is an extremely bad source to learn the language
Agree.
because its main purpose is not to explain the language, but to
describe the internal algorithms so make it possible to write
compliant engines for other than Netscape browsers.
No, it's purpose is to *define* the language. Not the internal
algorithms, but the syntax and semantics of it.
The algorithms given in the specification is not something you must
follow, as long as what you do gives the same result.
I must admit that there are places where the format has affected
the specification more than I think is necessary.
In this case, that's not relevant, though, because we are talking
about syntax.
The difference is
as between say a Perl user reference and comments for C libraries used
for Perl processor.
As the result some regulars know some really refined internal
mechanics, some of which even never did into any actual
implementation, yet having troubles to get some obviousnesses. In the
particular and most importantly they are normally having big time
troubles to distinguish *language* features and *underlaying C-based
engine* features and consequently having troubles to separate properly
tokenizing, parsing and execution stages, so applying terms and
entities from one stage to another and vice versa.
I do think you have a point, but your presentation of the point
is marred by you making the same mistake of mixing terminology from
different phases.
One more time, very slow: parsed by the rule of an identifier !== to
be an identifier.
Here you seem to have an idea what it means to be an "identifier".
In Javascript, being an identifier is a tokenization concept. The
thing you seem to think about is called "variable".
In object constructor all key values are string
literals, explicitly or implicitly quoted.
The concept of "string literal" is again a tokenization/parsing
concept. String literals are sequences of characters flanked by either
single or double quotes. They are parsed, and evaluated into string
values.
You cannot quote a string value. Being quoted is a syntactic concept,
which happens even before tokenization.
Again, we are taking about
JavaScript, so about the execution stage. What and how exactly C
program treats the source code stream is irrelevant here yet might be
interesting in other circumstances.
Which is, perhaps, why your explanation isn't being accepted - you uses
parsing/tokenization concepts it.
....
It is the full syntax because in object constructor all key values are
string literals, explicitly or implicitly quoted. Again, we are taking
about JavaScript, so about the execution stage. What and how exactly C
program treats the source code stream is irrelevant here yet might be
interesting in other circumstances.
See right above.
You can't add quotes after tokenization, so if you say that quotes
are added, it must be at the level of tokenization, at the latest.
My guess is that this better matches what you mean:
In object literals, all keys are string values. They can be written
as string literals, or as identifiers or number literals, which is
then converted to string values. Identifiers may not include language
keywords, and numbers are always converted to their canonical string
form, so if, e.g., "default" or "3.0" is used as a key, it must be quoted.
/L