![]() | |
#21
| |||
| |||
|
|
On Jan 6, 3:40 pm, John G Harris <j... (AT) nospam (DOT) demon.co.uk> wrote: Here's an example that destroys VK's argument : if (x) ; else x = 3; The lonely semicolon must be translated into code that jumps over the 'else' part. It can't be thrown away by the parser and forgotten. Right the opposite, it makes my case even stronger (about some free- lancers filling some - but not all - specs templates back in 90's). |
|
First of all you are getting _syntax_ error. [...] |
#22
| |||
| |||
|
|
VK wrote: On Jan 6, 3:40 pm, John G Harris <j... (AT) nospam (DOT) demon.co.uk> wrote: Here's an example that destroys VK's argument : if (x) ; else x = 3; The lonely semicolon must be translated into code that jumps over the 'else' part. It can't be thrown away by the parser and forgotten. Right the opposite, it makes my case even stronger (about some free- lancers filling some - but not all - specs templates back in 90's). It doesn't. First of all you are getting _syntax_ error. [...] No, anyone outside of your parallel universe does not get a syntax error. |
#23
| |||
| |||
|
|
On Jan 7, 12:47 am, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de wrote: VK wrote: On Jan 6, 3:40 pm, John G Harris <j... (AT) nospam (DOT) demon.co.uk> wrote: Here's an example that destroys VK's argument : if (x) ; else x = 3; The lonely semicolon must be translated into code that jumps over the 'else' part. It can't be thrown away by the parser and forgotten. Right the opposite, it makes my case even stronger (about some free- lancers filling some - but not all - specs templates back in 90's). It doesn't. First of all you are getting _syntax_ error. [...] No, anyone outside of your parallel universe does not get a syntax error. Use some descent (more-or-less standard compliant) browser then: script |
|
if (x) else x = 3; |
#24
| |||
| |||
|
|
The `type' attribute is missing. if (x) else x = 3; That is _not_ the example John gave above. You will get a syntax error with *yours*, because your assumption that `;' is not a(n empty) statement and is only important as a "parser helper" |
#25
| |||
| |||
|
|
[...] Thomas 'PointedEars' Lahn [...] wrote: The `type' attribute is missing. if (x) else x = 3; That is _not_ the example John gave above. You will get a syntax error with *yours*, because your assumption that `;' is not a(n empty) statement and is only important as a "parser helper" |
|
and all the conclusions you have subsequently jumped to are complete utter nonsense. Very true: it just not an assumption but exactly how any compliant engine mechanics work. |
#26
| |||
| |||
|
|
On Jan 6, 3:40 pm, John G Harris <j... (AT) nospam (DOT) demon.co.uk> wrote: Here's an example that destroys VK's argument : if (x) ; else x = 3; The lonely semicolon must be translated into code that jumps over the 'else' part. It can't be thrown away by the parser and forgotten. Right the opposite, it makes my case even stronger (about some free- lancers filling some - but not all - specs templates back in 90's). |
|
Incidentally, that semicolon can't be left out. If you want to do nothing you have to write the semicolon to show you really mean it. I don't really like to torture the syntax like that :-) To do nothing simply use brackets: if (something) {} else {do_this();} snip |
#27
| |||||
| |||||
|
|
On Jan 7, 1:29 am, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de wrote: The `type' attribute is missing. if (x) else x = 3; That is _not_ the example John gave above. You will get a syntax error with *yours*, because your assumption that `;' is not a(n empty) statement and is only important as a "parser helper" Very true: it just not an assumption but exactly how any compliant engine mechanics work. if (x) ; else x = 3; and if (x) else x = 3; are only different that the firs one gives enough info to parser to build a valid token chain and the second does not so leads to a syntax error. There is not any mythical EmptyExpression |
|
involved in neither case because it has no relation to the runtime (actual code execution). From John's comments to his sample: "The lonely semicolon must be translated into code that jumps over the 'else' part. It can't be thrown away by the parser and forgotten." - one could wrongly conclude that if-else statement requires at least one expression |
|
in the if-branch or it will error out at runtime. There is not such requirement for if-else |
|
and if (x) {} else {} is a perfectly valid - though rather useless - construct. |
|
There is i) the parsing stage when parser tries to build a valid sequence of valid tokens and gives syntax errors if no way, and ii) execution stage when the engine is actually trying to execute requested part of resulted tokens and gives runtime errors if no way. These are two absolutely different unrelated stages. Semicolons are used on the first (parsing) stage; there is not any smell of them on the second (execution) stage. snip |
#28
| |||
| |||
|
|
On Sun, 6 Jan 2008 at 13:27:40, in comp.lang.javascript, VK wrote: Right the opposite, it makes my case even stronger (about some free- lancers filling some - but not all - specs templates back in 90's). Pascal has the Empty Statement, back in 1970. |
#29
| |||
| |||
|
|
On Mon, 7 Jan 2008 at 07:46:32, in comp.lang.javascript, VK wrote: On Jan 7, 1:29 am, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de wrote: The `type' attribute is missing. if (x) else x = 3; That is _not_ the example John gave above. You will get a syntax error with *yours*, because your assumption that `;' is not a(n empty) statement and is only important as a "parser helper" Very true: it just not an assumption but exactly how any compliant engine mechanics work. if (x) ; else x = 3; and if (x) else x = 3; are only different that the firs one gives enough info to parser to build a valid token chain and the second does not so leads to a syntax error. There is not any mythical EmptyExpression If you don't know the difference between an expression and a statement then you shouldn't be talking about syntax. involved in neither case because it has no relation to the runtime (actual code execution). From John's comments to his sample: "The lonely semicolon must be translated into code that jumps over the 'else' part. It can't be thrown away by the parser and forgotten." - one could wrongly conclude that if-else statement requires at least one expression Again, if you don't know the difference between an expression and a statement then you shouldn't be talking about syntax. |
|
in the if-branch or it will error out at runtime. There is not such requirement for if-else The code generator needs to produce code that jumps over the else part. It's not the job of the code generator to understand the syntax, and therefore notice that there is (ok) or isn't (error) a statement token between the if condition and the else part. and if (x) {} else {} is a perfectly valid - though rather useless - construct. Now explain why an empty block is less 'mythical' than a no-op. There is i) the parsing stage when parser tries to build a valid sequence of valid tokens and gives syntax errors if no way, and ii) execution stage when the engine is actually trying to execute requested part of resulted tokens and gives runtime errors if no way. These are two absolutely different unrelated stages. Semicolons are used on the first (parsing) stage; there is not any smell of them on the second (execution) stage. snip There is no smell because the lonely semicolon has been translated into an internal token that the code generator/executor understands. |
#30
| |||
| |||
|
|
Guys (both of you): I am not in disposition to attack anyone's personal believes. Anyone is entitled to believe or do not believe in God, paradise, hell, bigfoot, alien conspiracy, EmptyExpressions, EmptyStatements and anything one would wish. |
|
I'm out of this thread. |
![]() |
| Thread Tools | |
| Display Modes | |
| |