VK wrote:
Richard Cornford wrote:
>"be liberal in what you accept and strict in what
you send".
Exactly: and this rule (which is especially true for javascript
engines) is violated on Opera 9.
It all goes straight over your head, doesn't it? You have complete
control over the code you write, but you would rather blame a web
browser for doing no more than it claims to do than learn how to take
control of the code you write.
The rule is that a javascript program
may error out only if no available interpretations left: this is why
even utterly wrong scripts are "working" sometimes -
Finally a subject where you have some experience.
but often not in the intended way.
The exact parsing algorithm was given by you in this thread,
No it was not.
as well as two possible branches of this algorithm.
I certainly mentioned that the only two applicable target constructs
were either Statements or Function Declarations.
<script type="text/javascript">
function(){}
</script>
1) Found "function" keyword left hand side, searching for identifier.
There is no sense in "left hand side". the keyword would be the next
token in a sequence where all preceding tokens (if any) were accounted
for.
2) If an identifier found then this is FunctionDeclara tion;
It is not a FunctionDeclara tion unless it fully satisfies the
production rules for FunctionDeclara tion.
if not then go to step 3
3) No identifier found, left hand side anonymous function.
Anonymous functions don't have sides. And is Function Declaration is
excluded the target construct is now Statement.
If Opera 9
then go to step 4, otherwise go to step 5
4) Opera 9: "booh, booh... bad syntax... :-("
Or, you now know you have messed up and can do something about fixing
your code.
(Also, you are assuming that Opera 9 is the only browser that will
apply the syntax rules in accordance with the specification. It almost
certainly is not, and indeed it would be more rational to assume that
all browsers would apply the language's syntax rules and then be
surprised at the few that are tolerant of this type of error).
4) Others: function expression w/o assignment, seems useless
but not our damn business.
And now you have someone who thinks that what they have done is
correct, and will probably be going on to repeat their mistake on the
grounds that it "works", even though it is then no more than a mystical
incantation repeated because it has been used in code that "works" in
the past and has not directly caused problems (at least under
superficial testing).
I don't need to tell you anything about programming by mystical
incantation, or superficial testing, as you are certainly the expert in
those areas.
This way Opera 9 between i)trying to further interpret the code and ii)
error out is choosing to error out, which is not OK for a reliable
script engine.
It is that sort of thinking that results in the code you write, which
is anything but reliable.
Richard.