top | item 24912760

(no title)

asynchrony | 5 years ago

How does it handle symbols that aren't legal javascript identifiers? Is that on the user or are the some safety conventions in place in the compiler?

discuss

order

an_ko|5 years ago

During compile-time, it doesn't care. So you can use "illegal" characters for the names of macros.

  (macro what? (function () (return '(a b c))))
  (what?)
That compiles just fine to the JavaScript code

  a(b, c);
It does try to validate identifier names during code generation though (using the esvalid module), so if you give it

  (? 1 2)
then it will error with

  [Error] Identifier `name` member must be a valid IdentifierName
  At line 1, offset 1:

  (? 1 2)
(In a terminal, the offending character is highlighted.)