namespaces and expression-qualified names

Jeff Dyer jodyer at
Fri Mar 21 08:12:38 PDT 2008

On 3/21/08 12:50 AM, Jon Zeppieri wrote:

> On 3/21/08, Brendan Eich <brendan at> wrote:
>>  I believe the intention among the core ES4 group over the last couple
>>  of years has been to support runtime qualifiers in ES4, as well. JS
>>  has computed property names since day 1: o[id] to access o.p. An
>>  optional strict mode can't reason about these, but they aren't the
>>  only loophole (eval, with, global non-fixtures). Why rule out runtime-
>>  computed qualified names (with either part computed at runtime)?

This has been our intent, and what is implemented in AS3 (FWIW). It seems
arbitrary and unnecessary to require qualifier expressions to be compile
time constants. Correct me if I'm wrong, but isn't one of the common
legitimate uses of 'eval' to computed lexical references? Computed names
give users a chance to do so with better syntax and semantic checking.

As for lexical references with computed identifiers, ES4 also supports the
following form:


where expr1 and expr2 are both computed at runtime.

> I'm talking about lexical bindings.  I agree with you about object
> properties; computed names are already the norm.  For lexical
> bindings, the situation (if I understand it correctly) is different.
> Because of the way eval is actually implemented in current engines,
> it's impractical (or maybe strictly impossible?) to resolve lexical
> lookups ahead of time.  With ES4, though, only the operator form of
> eval will be able to modify lexical environments, and its use can be
> statically detected.  Any environments that can be affected by the
> eval operator can be known at compile time, and they can use slow
> lookup.  The same holds for with statements.
> And, I think, the same would hold for runtime qualified names... but
> do you really want to add another way to defeat compile time lookup?

Names that can be resolved at compile time won't (can't) change meaning at
runtime. And names that are qualified by constant namespaces that appear in
the (safe) contexts you describe above can be resolved at compile-time. So I
don't understand your charge of runtime qualifiers "defeating compile time
lookup". Please elaborate.


More information about the Es4-discuss mailing list