Ye olde arguments argument (was: Topic list - pending changes and issues for the ES3.1 spec)

Mark S. Miller erights at google.com
Tue Sep 9 11:32:49 PDT 2008


On Tue, Sep 9, 2008 at 9:21 AM, Mark S. Miller <erights at google.com> wrote:
> How to restrict 'arguments' in strict functions?
>    anticipation of ES-H-strict -- prohibit co-existence with splat
>    arguments.callee
>    joining? frozen?

If we were making the jump from ES3 directly to ES-Harmony, we would
probably prohibit the magic 'arguments' object in ES-Harmony strict
functions, since its functionality is better served by optional and
rest parameters. However, ES3.1 won't have optional and rest
parameters, so 'arguments' will remain as the only way to do var-args
functions in ES3.1-strict code. Given that ES-H-strict is upwards
compatible from ES3.1-strict, this prevents us from prohibiting
'arguments' in ES-H-strict. The most we can do (which we should do) is
prohibit 'arguments' in strict ES-H functions which use optional and
rest parameters. (This is upwards compatible, since these features are
new.) However, ES-H-strict must still allow 'arguments' in other code.
If strict 'arguments' is to be better behaved and upwards compatible,
we must make the critical fixes in ES3.1-strict.

Currently, the ES3.1 draft spec says that strict 'arguments' has no
callee property. Should it instead specify an initial callee property
that throws if accessed? This would give better diagnostics from
migrating old code to strict. OTOH, making it absent is more
consistent with the normal JavaScript feature-testing style. (In a
separate note, I'll explain why we want the otherwise-unspecified
Function.caller, Function.arguments, and arguments.caller to throw for
strict functions.)

Strict 'arguments' should not be joined to its function's parameters.
In order to get better diagnostics for migrating old code to strict,
should 'arguments' also be frozen?

Should strict 'arguments' be an array? I know we've over this before
and that strong reasons were presented why we couldn't do this. But on
the ES3.1 phone call this morning no one could remember or regenerate
those reasons. Anyone? Pointers to previous threads are a fine answer.
Thanks.

-- 
    Cheers,
    --MarkM


More information about the Es-discuss mailing list