"Evertjan." <exjxw.hannivoort@interxnl.net> writes:
[color=blue]
> Since when is a statement not a statement if the subsequent syntax is not
> according to the rule book?[/color]
What do you mean by "subsequent"?
The syntax of an "if" statement is:
keyword "id"
left parenthesis, "("
expression
right parenthesis, ")"
statement
(optional: keyword "else" + statement)
Omitting the parentheses makes it no more an "if" statement that
omitting "function" makes something a function declaration.
[color=blue]
> In your definition, which is not mine, a
> statement can never be syntactically incorrect, it seems.[/color]
Exactly.
In fact, if the syntax is incorrect, not only isn't it a statment,
it's not even Javascript (or maybe more correct, not even ECMAScript,
since Javascript doesn't have as exact a definition).
A syntax error is just that: an error. It might have been intended
to be a statement, but it isn't.
[color=blue][color=green]
>> (I don't know what "erroring out" means).[/color]
>
> Does it give an error or does it work as intended [by me and anyone
> reasonable]?[/color]
It gives an error. It fails to compile correctly, which also means
that the entire file/script element it is in, is ignored.
[color=blue]
> There is a big difference between syntactical correctness and
> a working script, in both possible scenarios: Some syntactical incorrect
> scripting works,[/color]
Correct. Some interpreters allow things not in the official syntax,
like function declarations inside block statements or <!-- for comments.
This is not one of those. You can no more omit the parenteses of an
if expression than you can those of a while, switch or for expression.
[color=blue]
> some syntactical correct scripting doesn't and then you
> get an error, a crash or an unforseen and inintended result.[/color]
That would be a runtime error, e.g., accessing a property of the null
value.
[color=blue]
> In those two circumstances it the working incorrect script seems
> preferable.[/color]
Not working at all is preferable to working incorrectly. :)
/L
--
Lasse Reichstein Nielsen -
lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'