Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
no more identifiers with accented characters #5348
Original bug ID: 5348
Just update to 3.12.0 and, on MAC OS 10.6.8 the accented characters are no longer usable:
let carr?? x = x*x;;
Error: Illegal character (?)
The ?? was é
And under emacs:
let carré n = n * n;;
Comment author: @xclerc
Well, I am not sure it is an OCaml issue.
Your can change the terminal encoding in the "Advanced" pane
Comment author: gerd
Maybe the real issue is: ocaml should support UTF8 identifiers (instead of Latin1). Almost the whole world switched to UTF-8 in the meantime (e.g. many Linux distros use it as default now), and it becomes more and more painful that ocaml is so old-fashioned.
The full solution is complicated to implement, though - ocamllex would have to be changed so it can deal with multi-byte encodings. But as a tiny step into this direction, ocaml could at least allow UTF-8 as external encoding but keep Latin1 as internal encoding. That would mean a recoding step for every identifier that is read or written.
Comment author: @alainfrisch
Damien: What about a warning that reports accented letters in identifiers as a deprecated feature?
Gerd: It would be weird to accept UTF8 identifiers, while still parsing string literals as sequences of bytes (i.e. if we assume the source code to be utf8-encoded, String.length on a string literal would not return the length of the literal seen as a sequence of Unicode code points, unless you also change the semantics of strings, but I don't think you propose that).
Comment author: gerd
Alain: I agree that a complete solution would also include a Unicode version of "string", maybe called ustring, and with literals like U"xyz". I don't think we should redefine "string", because there is also a need for byte arrays, and we would run into endless compatibility problems. So, having both string and ustring would be the ideal world. I see that there are currently not enough resources for getting there, and the question is how many elements we can nevertheless implement. That could also mean to only deprecate accented letters at the moment.
Btw, for ustring we won't need that much, given that we accept that ocaml only provides basic Unicode support (string literals, one possible representation (ustring = int array), basic input/output, ocamllex), and leave the rest (alternate representations, character classes, transformations, ...) to add-on libraries like Camomile.
But anyway, I hope there is at least consensus that Unicode support is essential nowadays. The world is changing, and it has become irrelevant that Latin1 is still sufficient for most languages.
Comment author: @dbuenzli
In my opinion, a first good step would be to
The main of advantage of this is that it allows to write UTF-8
To me UTF-8 identifiers are more a curse than a benefit because
I have written many programs that deal with unicode by just UTF-8
Regarding having unicode string support in the distribution. I'd