Alternative syntax for <|
David Herman
dherman at mozilla.com
Thu Nov 17 08:40:05 PST 2011
On Nov 17, 2011, at 8:00 AM, Jason Orendorff wrote:
> On Wed, Nov 16, 2011 at 1:12 PM, Erik Arvidsson
> <erik.arvidsson at gmail.com> wrote:
>> One thing that all of these discussions are missing is the hoisting
>> property of function and any possible future classes. If we use "let
>> Point = ..." we lose all hoisting and the order of your declarations
>> starts to matter and we will end up in the C mess where forward
>> references do not work.
>
> Can you give sample code where this is really a problem?
People take advantage of the fact that they can define their functions wherever they want in JS and they'll already be initialized. It's perfectly reasonable to have a bunch of classes and want to group them together thematically, and not have to sort them in order of initialization.
> I think it's a problem in C/C++ because of early binding and because
> the C/C++ parser has to recognize typenames.
>
> In ES, the scope of "let Point = ..." is the enclosing block, right?
> Forward references should work fine.
This isn't about scope, it's about at what point they're initialized. If you write:
let x = new C();
let C = class /* whatever */;
you won't get a scope error but a runtime initialization error. Whereas if you write:
let x = new C();
class C { ... }
it'll work fine.
I'm with Arv 150% on this.
Dave
More information about the es-discuss
mailing list