What programming languages allow you to define names of variables, classes and functions using Unicode symbols?
views:
78answers:
4
+2
A:
There are many of them. The most popular being Java (see another answer here, http://stackoverflow.com/questions/1422655/java-unicode-variable-names). Python 3 also supports unicode letters in identifier names.
Tõnis M
2009-11-23 21:49:07
+3
A:
Certainly C#, and I believe java:
using משליט = System.Object;
using תוצאה = System.Int32;
public class שלום : משליט {
public תוצאה בית() {
int אלף = 0;
for (int λ = 0; λ < 20; λ++) אלף+=λ;
return אלף;
}
}
Marc Gravell
2009-11-23 21:49:16
It is however not recommended to use smth. like this in an international project :)
psihodelia
2009-11-23 21:53:24
Java definitely allows that (didn't want to edit your post, this doesn't really feel like a "fix" to me).
Joachim Sauer
2009-11-23 21:54:17
Btw, I always found it good that Unicode support is finally so widely available, but never used it (usually all my code is english-language only, although German is my native language). But I never thought about the implications of LTR scripts in programming code. It definitely breaks the text flow when the language and its keywords is RTL and the identifiers are not (or even worse: they are mixed). The `int` variable definition above renders as `int 0 = <hebrew characters>;` for me, which looks ... very, very strange. But maybe that looks normal to someone who's used to that script.
Joachim Sauer
2009-11-23 21:59:06
I fully agree - very strange looking, and definitely not code I'd want to debug. Now imagine the fun you could have with 17 (or however many) different variants of "i" ;-p
Marc Gravell
2009-11-23 22:06:15
+1
A:
Even C++ does ! The list is really to big to collect here.
Although I expect Unicode to be hell for languages that claim to be case-insensitive. After the statement Σ = 0
, which of the following statements is true? ς == 0
or σ == 0
? And assuming it would be the last, does that mean that the statement σ = 0
implies that ς == 0
? (Σ is the Greek uppercase Sigma; ς and σ are its two lowercases).
MSalters
2009-12-02 11:43:24
This is one of the reasons why case-insensitivity is often not a great idea from a coding perspective; if you treat every codepoint as distinct, you're fine. Beyond that, have fun trying to establish the equivalence mappings... :-)
Andrzej Doyle
2009-12-02 11:49:42
Yup, you need a transistive symmetric reflexive relation between characters for that.
MSalters
2009-12-02 13:27:53