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

> Why not using something more of the lines with Ruby's :symbol syntax?

Because Ruby's symbols are completely different and designed to collide. A Ruby symbol (like an Erlang atom) is a very cheap immutable string-like structure but :symbol is :symbol.

A Javascript symbol is (as others noted) much closer to a lisp unique symbol (the output of `gensym`), and having it be a function is perfectly fine since you have to keep it around anyway (or you can't access symbol-named properties).

Symbol.for is roughly equivalent to :symbol, but the use case for it is much more limited and there's really no reason for a literal version./



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

Search: