HighDots Forums  

statement values

Javascript JavaScript language (comp.lang.javascript)


Discuss statement values in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #21  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: statement values - 01-06-2008 , 03:47 PM






VK wrote:
Quote:
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.

Quote:
First of all you are getting _syntax_ error. [...]
No, anyone outside of your parallel universe does not get a syntax error.

This group would benefit most from your dreaming your fantasies elsewhere.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16


Reply With Quote
  #22  
Old   
VK
 
Posts: n/a

Default Re: statement values - 01-06-2008 , 04:22 PM






On Jan 7, 12:47 am, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de>
wrote:
Quote:
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;
</script>

gives:

Fx: Tools > Error Console
"Error: syntax error"

IE (error message allowed):
"Syntax Error"

feel free to try on Opera, Safari or any other off your fantasy. I'm
paying $$ for each _runtime_ error


Reply With Quote
  #23  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: statement values - 01-06-2008 , 04:29 PM



VK wrote:
Quote:
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
The `type' attribute is missing.

Quote:
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.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee


Reply With Quote
  #24  
Old   
VK
 
Posts: n/a

Default Re: statement values - 01-07-2008 , 09:46 AM



On Jan 7, 1:29 am, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de>
wrote:
Quote:
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.

For further fun of it:

<script>
var code = 'if (true) {3;;}';
alert(eval(code)); // 3
</script>

but the main proof is the memory state of course - if anyone still
feel to be needed a proof of something.


Reply With Quote
  #25  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: statement values - 01-07-2008 , 12:25 PM



VK wrote:
Quote:
[...] 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"
You snipped, probably intentionally:

Quote:
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.
No, it isn't. You have already been proven wrong.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16


Reply With Quote
  #26  
Old   
John G Harris
 
Posts: n/a

Default Re: statement values - 01-07-2008 , 01:58 PM



On Sun, 6 Jan 2008 at 13:27:40, in comp.lang.javascript, VK wrote:
Quote:
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).
Pascal has the Empty Statement, back in 1970.


<snip>
Quote:
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

Now you're talking about coding styles : empty statement versus empty
block statement.

Also, if ; is syntax torture then so is {}.

John
--
John Harris


Reply With Quote
  #27  
Old   
John G Harris
 
Posts: n/a

Default Re: statement values - 01-07-2008 , 02:45 PM



On Mon, 7 Jan 2008 at 07:46:32, in comp.lang.javascript, VK wrote:
Quote:
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.

Quote:
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.

Quote:
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.

Quote:
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.

Quote:
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.

John
--
John Harris


Reply With Quote
  #28  
Old   
Dr J R Stockton
 
Posts: n/a

Default Re: statement values - 01-08-2008 , 10:20 AM



In comp.lang.javascript message <QnKHhvGzRogHFwG9@J.A830F0FF37FB96852AD0
8924D9443D28E23ED5CD>, Mon, 7 Jan 2008 19:58:43, John G Harris
<john (AT) nospam (DOT) demon.co.uk> posted:
Quote:
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.
Algol 60 Report :-
4.4.1 Syntax
<dummy statement> ::= <empty>

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.


Reply With Quote
  #29  
Old   
VK
 
Posts: n/a

Default Re: statement values - 01-08-2008 , 10:25 AM



On Jan 7, 11:45 pm, John G Harris <j... (AT) nospam (DOT) demon.co.uk> wrote:
Quote:
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.
OK, that's getting boring. Are you gonna talk on the subject or on the
posting style?

Quote:
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.
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.




Reply With Quote
  #30  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: statement values - 01-08-2008 , 11:36 AM



VK wrote:
Quote:
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.
It would appear that your problem is *exactly* your thinking that
programming can be understood in religious terms and mystical
incantations. Once you hopefully abandon that notion eventually, it
will become much easier for you to really *understand* how things
work.

Quote:
I'm out of this thread.
Thanks.


PointedEars


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.