Garrett said:
I would avoid that, too, for the same reason. Using |arguments|
prevents
an implementation from making an optimization.
| 10.1.8 Arguments Object
|
| When control enters an execution context for
| function code, an arguments object is created
| as follows: [...]
Did you get that now? There can be no real optimization here unless the
implementation would forego standards compliance. And I (and others)
have already demonstrated that because of the dynamic nature of the
language it is virtually impossible for an implementation to determine
use or non-use of the ‘arguments' object before execution.
An ECMAScript implementation guarantees behavior.
Nonsense. The Specification could not be clearer in that regard, and
implementors are well-advised not to try any "optimizations" here.
(So much for debunking
an "unfounded assuption"). If a function body does not make a
reference
to |arguments| or |eval|, an implementation could create an optimized
call for that function.
The resources that would need to be invested to determine before
execution if there really is an reference to the arguments object are
better spent elsewhere.
Implementations may make a static analysis of the function to
determine
if an optimized call can be performed and perform such optimized call,
if the side effects of such call would not be observable
Nonsense.
It has been demonstrated that implementations actually seem to do
this.
Then their implementors are at fault, and the change should be reverted,
better sooner than too late.
However, it the question is to determine if a function foo:-
function foo(x){
alert(x === undefined);
}
- has been passed an argument, as in:-
foo(undefined)
- as opposed to -
foo()
- would be to check the arguments object.
10.1.3 guarantees that missing parameters get value |undefined|.
No, it doesn't:
undefined = "foo";
We've been over this. There is one bullet-proof way to determine if an
argument has been passed or not: checking arguments.length.
| If the caller supplies fewer parameter values than there are formal
| parameters, the extra formal parameters have value undefined.
undefined != ‘undefined’
or, if you prefer the less ambiguous version:
typeof undefined != "undefined"
This has been discussed on here in detail before.
But apparently you haven't been paying attention then either.
PointedEars