3 ms·
Author here. Even in languages that allow for them, Unicode chars in identifiers are rarely used. They carry some costs that may matter a great deal: they can
by cemerick 15y ago
Author here.
Even in languages that allow for them, Unicode chars in identifiers are rarely used. They carry some costs that may matter a great deal: they can make certain tools unusable with a given codebase, they can act as hurdles to contributors, and they can act as hurdles for users of libraries ("what the hell is ε?!", etc). However, if you know your audience, and know your contributors, and generally know what you're doing, have at it.
All those same costs apply if you're using Unicode characters as part of your language's syntax, and the user confusion issue is exacerbated if the characters are entirely equivalents to other bits of syntax that approximate what the Unicode chars may encode precisely.
For example: at least some parts of Akka switched over to using Unicode arrows instead of the ASCII approximations[1]. Will contributions to Akka that use ASCII arrows now be rejected? How many times will Akka leads have to point surprised potential new contributors to whatever part of the Scala spec allows for Unicode arrows? God help the poor soul that would like to do some Akka hacking on a Windows box. Etc.
All this is worth the slight prettification? Presumably, the answer is "yes". As I said, we can all make our own judgments.
[1] https://github.com/jboner/akka/commit/554bb3eb293fe083dcc4fd0fcb8e0b23bd566e5b#L5L82 https://github.com/jboner/akka/commit/554bb3eb293fe083dcc4fd...
- drtse4 15y ago"Will contributions to Akka that use ASCII arrows now be rejected?" I guess that this will be solved and has been solved in that commit with a formatting tool, but for me the answer to your last question is definitely "no", putting unicode arrow "aliases" in the language is a completely useless cosmetic feature. How many programmer will type a unicode arrow manually? Is this really necessary? I'm generally against adding purely cosmetic feature like this one, if it does not improve the language in a clear and tangible way, just leave it out.
- fhars 15y agoCode redability is more importand that saving a keystroke, and code that looks less ugly is easier to read. You should view the ascii replacements like => like you view the trigraph replacements C allows you to write if you editor or terminal don't allow exotic characters like {.
- regularfry 15y agoCode that is difficult to write is difficult to rewrite. I'm not sure I know how I'd type a unicode back-arrow without menuing through a character map or copying and pasting it from somewhere.
- benblack 15y agoThe formatting tool in question defaults to _not_ doing this, specifically to comply with the Scala Style Guide which does _not_ do this. The tool had to be explicitly configured to make this unfortunate change.
- JamieEi 15y agoI don't understand the concern about typing non-ASCII Unicode characters on a Windows box. I know of at least 3 easy ways: charmap, alt+numpad, and editor-specific support.