Languages like Haskell allow you to create your own operators. The following answer explains which punctuation characters are allowed in operators: https://stackoverflow.com/a/10548541/783743
Languages like JavaScript on the other hand do not allow you to use punctuation character (beside $
) in your variable names. [1]
I am writing a compiler which compiles a subset of Haskell to JavaScript and I don't know how to convert the operators into valid JavaScript identifiers.
Hence I decided to map each punctuation character to a basic latin lowercase alphabet (i.e. a-z
). For example:
& = a
| = l
@ = q
However instead of deciding the character mapping for myself, I first want to know whether anybody else has already done the same thing or whether there's a standard which decides how to map them.
I realize that this question could become primarily opinion based (which for some reason is strictly disallowed on StackOverflow). Hence I'm only looking for canonical answers which state definitively that "this is the way to do it" (perhaps with a link). If you want to opine then you can do so in the comments.
There are currently 19 characters which I wish to map to alphabets:
! # $ % & * + . / < = > ? @ \ ^ | - ~
Although $
is a valid character for identifiers in JavaScript it would be nice to map it to an alphabet too.
[1] Property name can have special characters, but that's an ugly hack.