# Propose simpler string constant

Coroutines coroutines at gmail.com
Fri Dec 18 01:02:43 UTC 2015

```On Thu, Dec 17, 2015 at 1:42 PM, Rick Waldron <waldron.rick at gmail.com> wrote:

> Anyway, this is the WIP http://rwaldron.github.io/enum-definitions/

I like how this looks.

If a value is not assigned to one of the enumerated identifiers, it's
assumed that you're defining all symbols (as you're not hinting at an
order or using a pooled (in memory) value).

What I had thought about was this:

enum { A B C } # A, B, and C become const Symbol references
(Symbol('A'), Symbol('B'), Symbol('C'))

enum { A = 0, B, C }  # A, B, and C become const number references (0, 1, 2)

enum { A, B = 'bat', C }  # A, B, C become const string references
('A', 'bat', 'C')

enum { A, B = 2, C = 'cat' } # becomes: const A = 'A'; const B = 2;
const C = 'cat';

enum whatever { ... };  # would just become: var whatever = { ... } of course

My reasoning is this:

By assigning a value to any of the identifiers within an enum, you are
not using the identifier as reference to a unique value (which means
you don't want what Symbol has to offer).

Basically if you attach a value to anything within an enum, the entire
enum DOES NOT define any Symbols.

If it's a number value and there are no other non-number values in the
enum: we order it like a C enum.

In a non-number or mixed-value enum, the identifiers default to
becoming the strings they reference: enum { CAT = 3, DOG = 'whatever',
FISH } # becomes: const CAT = 3; const DOG = 'whatever'; const FISH =
'FISH';

PS: disregard my lack of `let/var`
```

More information about the es-discuss mailing list