function hoisting like var

Ingvar von Schoultz ingvar-v-s at
Sat Jul 26 06:07:03 PDT 2008

Brendan Eich wrote:
> Waldemar meant precisely what he wrote: ES3 and draft ES3.1 -- the 
> specifications, not random JS implementations.

Oops, I got lost in details and strayed far away from the
point that I wanted to make. In fact I should have said
this from the beginning:

You can't get away from supporting this:

          function a(){}
          var b = a;

ES4 is planning to support function declarations locally
bound in blocks, so the above is valid ES4 code.

What you see above is function b() hoisting like var.

(I said b, not a.)

There is no far-too-complicated split-scope complexity. There
is no capturing of variables that haven't been declared yet.
It's simple, intuitive, well-defined and well-behaved.

The above is the /exact/ functionality of function hoisting
like var, apart from using two names. You can refuse the
clearer syntax, but you can't refuse the above code and

In other words, complexity is not a problem. ES4 can easily
choose whatever semantics people prefer.

Ingvar von Schoultz

------- (My quirky use of capitals in code comes from my opinion that
reserved and predefined words should all start with lowercase, and
user-defined should all start with uppercase, because this will easily
and elegantly prevent a host of name-collision problems when things
like programming languages are upgraded with new labels.)

More information about the Es4-discuss mailing list