Alternative syntax for <|

Jason Orendorff jason.orendorff at gmail.com
Thu Nov 17 10:17:27 PST 2011


On Thu, Nov 17, 2011 at 10:40 AM, David Herman <dherman at mozilla.com> wrote:
> 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.

I'm with Allen. If ES classes can contain any initialization code, I
think it should run in program order, interleaved with top-level
statements. Anything else is just confusing.

Note that classdefs in Ruby and Python aren't hoisted, and nobody
complains. In those languages classdefs very often contain procedural
code, for many purposes.

    class Card   # Ruby
        attr_accessor :rank, :suit    # macro-like
    end

    class File:  # Python
        size = property(get_size)    # create property descriptor
        if os.name == 'posix':    # ifdef-like
            ... posix-only methods ...

-j


More information about the es-discuss mailing list