6 ms·
Perl 5 has been able to use UTF-8 identifiers for over a decade, but I don't know anyone who is actually using them. $ perl -e 'use utf8; $水=1; print $水,"\n"
by rwmj 16y ago
Perl 5 has been able to use UTF-8 identifiers for over a decade, but I don't know anyone who is actually using them.
$ perl -e 'use utf8; $水=1; print $水,"\n"'
1
- mahmud 16y agoThe first mainstream language with native support for Unicode was Java.
- chromatic 16y agoI've used them. The lambda CPAN module is more useful than it seems.
- rwmj 16y agoDo you mean this one? http://search.cpan.org/~ewilhelm/lambda-v0.0.1/lib/lambda.pm http://search.cpan.org/~ewilhelm/lambda-v0.0.1/lib/lambda.pm It's sort of telling that the manual page has a lengthy explanation about what to do if you can't see the symbol, and a vim macro that you need to install so you can type the symbol. And it's just one symbol saving 2 characters (and no keypresses) :-(
- zerohp 16y agoThe Go language mentioned in the article uses UTF-8 source code and allows any Unicode letter or digit to be used in identifiers. Just as you mentioned of perl, very few people use it.
- koenigdavidmj 16y agoIn particular, the case-of-first-character-in-identifier rule breaks foreign character sets, so they have to prefix public members with an X or something.
- d0mine 16y agoThe rationale to add non-ascii identifiers to Python: Python code is written by many people in the world who are not familiar with the English language, or even well-acquainted with the Latin writing system. Such developers often desire to define classes and functions with names in their native languages, rather than having to come up with an (often incorrect) English translation of the concept they want to name. By using identifiers in their native language, code clarity and maintainability of the code among speakers of that language improves. </quote> http://www.python.org/dev/peps/pep-3131/ http://www.python.org/dev/peps/pep-3131/ $ python3 -c '水=1; print(水)' 1 But I also don't know anyone who is actually using them.
- vorg 16y agoIn this example, i.e. 'print(水)', the Unicode symbol is being used within a syntax designed specifically for an Ascii vocabulary. If the syntax is changed to allow '打水' instead of 'print(水)', where the language parser knows the single CJK token 打 has a standalone semantic, then needless spaces can be removed.
- nitrogen 16y agoRight now computer programs written in common languages are internationally readable. It's bad enough having a language barrier in normal human communication. Why do we want to extend the language barrier to code, too? I don't care if it's not English, but there needs to be an internationally-accepted base character set and language for selecting programming language keywords, and that character set needs to be roughly the size of ASCII.
- kiujhgbnj 16y agofinally a way to make Perl easier to read