![]() | |
#61
| |||
| |||
|
|
VK <schools_r... (AT) yahoo (DOT) com> writes: However, the language's syntax rules give you three ways to name a property in an object literal, viz : *as an Identifier *as a *StringLiteral *as a *NumericLiteral No, the language gives you only one option to name a property in an object literal, this is a string literal. No! It is a string *value*! |
|
There are three ways to specify that string value: *Identifier, string literal and number literal. Please distinguish literals (syntax) from values (semantics)! |
#62
| |||
| |||
|
|
On Nov 1, 1:15*am, Lasse Reichstein Nielsen <lrn.unr... (AT) gmail (DOT) com wrote: VK <schools_r... (AT) yahoo (DOT) com> writes: No, the language gives you only one option to name a property in an object literal, this is a string literal. No! It is a string *value*! http://en.wikipedia.org/wiki/String_literal#Bracketed_delimiters Why is it important to say "string literal" and not "string value"? |
|
Because this is the point that distinguishes strings here: var s = 'foobar'; and say here: var s = 'foo'+'bar'; other words literal and expressions / return values / whatever which may well be string values. |
#63
| |||
| |||
|
|
Why is it important to say "string literal" and not "string value"? |
|
But why not just KISS? |
#64
| |||
| |||
|
|
Harris' variation: identifiers that identify string literals resulting from the parsing. snip |
#65
| |||
| |||
|
|
I suggested you were using 'identifier' as an alias for 'property name', the thing that identifies a property when the program runs. |
- is to stop writing

#66
| |||
| |||
|
|
P.S. var obj = new Object; obj[0144] = true; obj[-100] = true; for (p in obj) {window.alert(p);} Rather than create some really special programming terms and almost programming schools just take that the guys were too busy with other stuff when making JavaScript1.2 so just added implicit constructors with syntax shortcut atop already rather weird per-property constructor so the system is as it is but of course without any "non- identifying identifiers" and stuff. |
|
P.S.S. Yet of course some regulars already might have a set of definitions for say obj[-100] = true; without any "implicit quoting" |
|
But why not just KISS ? Only to be not like everyone? |
#67
| ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
|
|
You stated that:- "Object constructor property names are always treated as string literals, so quotes around them may be omitted in the source code to speed up typing and/or for a better code readability." Right. |
|
"due to some parser quirks they may lead to syntax errors" Right. |
|
"do not use the above mentioned syntax shortcut and to use full syntax with quotes around each property name" Right. |
|
There is no meaning to "quotes are omitted". The names used in object literals are one of Identifiers, string literals, or numeric literals. String literals are not string literals without quotes and Identifiers are not Identifiers with them. 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 |
|
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. |
|
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. Allowing Identifiers may be for simplicity (or maybe just because it seemed like a good idea, or was so obvious that it was never questioned and so has no motivation). There is no sense in "omitting" quotes being "allowed" for any reason, what is allowed is a choice of tokens. One more time, very slow: |
|
parsed by the rule of an identifier !== to be an identifier. |
|
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. but if quotes are omitted, some troubles are possible on the parsing stage so better to use them. The only possible trouble is that if the construct created does not conform with the syntax rules it will result in a syntax error. You call it "the only possible trouble"? It sounds like a joke "the worst what may happen with you - you may die" ![]() |
|
Simple and clear. Indeed |
|
As with much you write, it gets clearer as you edit more out. There is no more talk of "syntax shortcut", It is. "full syntax with quotes around each property name" 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. "the quotes will be added automatically" See right above. |
|
"one of reserved words in the parser list AND it changes its own previous decision" Right, and this is one of weak points of the current parser rules. |
|
Yet I understand that the productivity impact to accommodate this problem may be to serious to be practical. "it is not a constructor but a block of statements", "consider such code as a broken switch-case construction", etc. Here my interpretation was wrong. |
|
"False positive" because of "default" keyword as the troublemaker. Do not forget that the problem was obscured by say var obj = {class: 'foobar'} being just fine on Gecko, so it took a really unusual combination of factors to get an object constructor, being to lazy at the moment to type quotes and thinking that "default" as the last key would be a good name here. |
Yet you may order some champagne to celebrate if you wich ![]() You mean they are processed as Identifiers if they are Identifiers? They are not identifiers Yes they are. No they are not. See the preface of this post. You need to learn to distinguish the language and the underlaying engine. |
|
and they are not becoming identifiers out of being processed by this rules. If they were not Identifiers they would not be processed as Identifiers. ... still long way to go with you... An identifier, an expression, an object, a function are entities distinguished by their functions and by their usage in the *language*. |
|
Can you make an effort and to get out from the irrelevant lower level matters? |
|
It is JavaScript forum and we are talking about JavaScript here, not about C or C++ and how these languages are used to produce a functional JavaScript program out of the source text. |
|
The rest of post is the same delusion (or a trick?) to talk about JavaScript running program, source code, C/C++ parser rules at once in one sentence without any proper attribution of relevant parts to relevant aspect. |
#68
| ||||
| ||||
|
|
The identifier foo identifies a variable foo in the context of Global or function scope. |
|
In an implicit object constructor if used in the position of the property name it identifies ... |
|
Another option - other than claiming your quoted statement be a lore from the Alpha Centauri programming school - is to stop writing"identifier" and use "ECMA 262 3rd.ed. Identifier" with the necessary capitalization and proper reference so then make it clear that you are not talking about a programming entity but about a charcode sequence defined by such and such formal criteria. Then: |
|
1) What is the difference between a Harris' "parsing stage ECMA 262 3rd.ed. Identifier" on and an "identifier" in the casual programming sense in the program itself. snip |
#69
| |||||
| |||||
|
|
On Sun, 1 Nov 2009 at 12:33:54, in comp.lang.javascript, VK wrote: * <snip The identifier foo identifies a variable foo in the context of Global or function scope. In a 'with' statement it identifies a property if the 'with' object has a property with that name. |
|
In an implicit object constructor if used in the position of the property name it identifies *... * <snip |
|
Another option - other than claiming your quoted statement be a lore from the Alpha Centauri programming school - is to stop writing"identifier" and use "ECMA 262 3rd.ed. Identifier" with the necessary capitalization and proper reference so then make it clear that you are not talking about a programming entity but about a charcode sequence defined by such and such formal criteria. Then: You need glasses. I never *started* using 'identifier' when I meant 'Identifier'. |
|
When did source files stop containing 'programming entities' ? |
|
* <snip>>1) What is the difference between a Harris' "parsing stage ECMA 262 3rd.ed. Identifier" on *and an "identifier" in the casual programming sense in the program itself. * <snip We've been trying to work out what you mean when you write identifier. You seem to change your meaning every other paragraph. |
#70
| |||
| |||
|
|
On Nov 2, 10:56*pm, John G Harris <j... (AT) nospam (DOT) demon.co.uk> wrote: On Sun, 1 Nov 2009 at 12:33:54, in comp.lang.javascript, VK wrote: * <snip The identifier foo identifies a variable foo in the context of Global or function scope. In a 'with' statement it identifies a property if the 'with' object has a property with that name. Let's not talk about all things at once. Right now we are looking at an object constructor literal. |
|
In an implicit object constructor if used in the position of the property name it identifies snip |
|
All the way though I was very explicit by what does "identifier" mean in the programming (not in some "VK's thesaurus" or so): with 3rd source definitions, with samples of identifiers (not "ECMA 262 3rd.ed. Identifier") on the parsing and execution stage. You just need to follow the thread. |
![]() |
| Thread Tools | |
| Display Modes | |
| |