[erlang-questions] extend parser to allow single quotes in variable names (or: "let's confuse the text editors!")
Richard O'Keefe
ok@REDACTED
Sun Oct 7 23:44:45 CEST 2012
On 8/10/2012, at 5:35 AM, Motiejus Jakštys wrote:
> Hi,
>
> In Haskell you can have variable names with single quotes. Imagine for a
> moment you are in a perfect world:
>
> oops() ->
> A = 1024,
> A' = math:log(A) / math:log(2),
> io:format("Wow! ~p~n", [A']).
>
> What would you think about this extension?
I would think it was pointless.
Haskell Erlang
x X
x' X1
x'' X2
x''' X3
x'''' X4
x''''' X5
Spot the pattern?
Haskell (or at least GHC) allows primes inside identifiers too,
but nobody seems to take advantage of that.
Consider f'x 'y'. Want to read _that_ fast?
Consider f'x' y'. Want to tell them apart fast?
SML also allows primes inside and at the end of identifiers.
This is much less of a pain in SML because SML writes
character literals as #"x" rather than 'x'.
There is historically and in good typography a clearly visible
distinction between the apostrophe and the superscript I II III
IV V: (x' is x prime; x'' is x second; x''' is x third, and
the next one is x<sup><small>IV</small></sup>, x fourth, not
x''''). It's only the limitations of old typewriters and ASCII
that lead us to confuse them. Superscript Roman numerals in
Unicode identifiers, fine; using the apostrophe as the quote
character for atoms and also in identifiers, not fine.
More information about the erlang-questions
mailing list