Strict mode recap
jaz at bu.edu
Fri Apr 4 09:59:54 PDT 2008
On Fri, Apr 4, 2008 at 11:30 AM, Lars Hansen <lhansen at adobe.com> wrote:
> I don't get it.
> Your comment about inhibiting static analysis isn't right; if ns::x is a
> name then either ns is known to be constant at compile time or not, and
> if it is, then nothing prevents early binding. ES3 systems perform
> analyses that are inhibited by eval and with, and statically detect
> whether eval and with are used in order to decide whether to perform the
I think we understand different things by "inhibiting static
analysis." I'm not claiming that the inclusion of the feature makes
static analysis impossible -- only that the use of the feature can
severely limit its effectiveness. E.g.:
ns::[expr] = ...
... kills assignment analysis for any bindings in scope, and
ns1::[expr1] = ns2::[expr2]
... kills escape analysis similarly. (I think... although I'll
happily defer to you on this.)
Now, if you want to say that it's pay as you go -- that if you use the
feature, you incur the expense, and otherwise you don't -- I agree. I
just don't yet understand why anyone would want to do this with
activation objects. What are you paying *for*?
> Anyway, what's the distinction between "dynamic lookup of first-class
> object properties", as you write in a later message, and looking up a
> name in general, once you introduce namespaced bindings in packages and
> global objects (though not in local variables) and couple everything
> with 'with'?
I'm not sure I understand this. I can't answer your question about
namespaced bindings in packages, since I don't know what ES4 packages
are. I have some vague idea that they are sugar for namespaces, but
that may be wrong/obsolete. As for global objects, how does the
inclusion of namespaces affect lookup? Unlike activation objects,
globals aren't notional.
Oh, okay -- I think I follow you. So, in any given scope, ns::[expr]
may refer to a local activation object binding or it may refer to a
global one. (Forget 'with' for the moment.) I've been arguing that
this kind of name shouldn't be allowed for local lookups, but it
should be allowed for global ones. The problem is that you don't know
which it is until the lookup is actually performed.
Well, I'd be happy making the criterion purely syntactic: assuming we
aren't in a 'with' statement, ns::[expr] always refers to a global
binding (not including ns::[expr] to the right of a property operator,
of course.) In a 'with' statement, the with-ed object has to be
searched first. 'with' certainly complicates lookup, but as you've
pointed out before, its use is visible.
By the way, can a 'use namespace' pragma refer to a namespace via a variable?
> Are you saying I should be allowed to say (supposing
> namespace 'French' exists):
> but not
> var language = French
> ? What purpose does it serve to have this restriction if static
> analysis is not inhibited in the former case, as you wrongly claim it
Are you claiming that it's possible to perform early binding of
language::hello? (Assuming the example isn't actually as simple as
what you've written, I mean.)
More information about the Es4-discuss