I *do* fully agree with the notion that enums should generate Symbols by
default... however, it seems unreasonable to prevent users from assigning
other types as well.

Should enums also offer programmers the ability to assign explicit values,
as per traditional enum constructs? For instance, in TypeScript, coders are
able to assign values manually, or even elevate the initial index that
enumerations are counted from:

const colours = {
    Red = 1,
    Green, //  2
    Blue  // 3
};

We can probably do away with the initial index elevation (since enum'd
names would default to the Symbol representation of the identifier,
anyway), but I imagine many developers would expect to be able to assign
integers in JS enums the same way they can in C, et al.


On 16 December 2015 at 23:00, <es-discuss-requ...@mozilla.org> wrote:

> Send es-discuss mailing list submissions to
>         es-discuss@mozilla.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.mozilla.org/listinfo/es-discuss
> or, via email, send a message with subject or body 'help' to
>         es-discuss-requ...@mozilla.org
>
> You can reach the person managing the list at
>         es-discuss-ow...@mozilla.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of es-discuss digest..."
>
> Today's Topics:
>
>    1. Re: Propose simpler string constant (Coroutines)
>
>
> ---------- Forwarded message ----------
> From: Coroutines <corouti...@gmail.com>
> To: es-discuss <es-discuss@mozilla.org>
> Cc:
> Date: Wed, 16 Dec 2015 03:31:26 -0800
> Subject: Re: Propose simpler string constant
> On Wed, Dec 16, 2015 at 3:20 AM, Thomas <thomasjamesfos...@bigpond.com>
> wrote:
> > IMHO it'd be a huge mistake to not use symbols for enums.
> >
> > In my head this:
> >
> > const colours = enum {
> >   Red,
> >   Yellow,
> >   Green,
> >   Blue
> > }
> >
> > should 'desugar' to something like this in ES6:
> >
> > const colours = {
> >   Red: Symbol('Red'),
> >   Yellow: Symbol('Yellow'),
> >   Green: Symbol('Green'),
> >   Blue: Symbol('Blue')
> > }
> >
> > Thomas
>
> This person gets it. +1  :-)
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to