Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

ES6 already adds a ton of new constructs that won't run on older browsers. Relying on symbols to be interned also won't work on older machines. A symbol-literal syntax like #symbol and #"spaced symbol" would make them far easier to use and increase their adoption.

Who really wants to write map.add(new Symbol("foo"), 'bar') instead of map.add(#foo, 'bar')?



> Who really wants to write map.add(new Symbol("foo"), 'bar') instead of map.add(#foo, 'bar')?

It makes it clear when you are generating new symbol, and when you are reusing existing symbol.

    var a = new Symbol("foo");
    var b = new Symbol("foo");
    map[a]="firstValue";
    map[b]="secondValue";
    Console.log(map[a] + " " + map[b]);
    // writes "firstValue secondValue"
How does it work with your syntax?

    map[#foo]="firstValue";
    map[#foo]="secondValue";
    Console.log(map[#foo]); // what is written here?


> Who really wants to write map.add(new Symbol("foo"), 'bar')

Nobody because it's completely daft, and absolutely not equivalent to the second version, the equivalent to the second version is:

    map.add("foo", "bar")




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: