In my opinion they have no place in a language, but definitely belong in a default preprocessor. You may get the APL-keyboard problem though. (and possible visual ambiguity).
A limited example of this as a pre/post processing would be cweaved code.
In my opinion they have no place in a language, but definitely belong in a default preprocessor. You may get the APL-keyboard problem though. (and possible visual ambiguity).
A limited example of this as a pre/post processing would be cweaved code.
It's an interesting concept, but aren't you worried that multiple spellings of the same thing will make parsing the code more difficult, especially for IDE's? Not to mention the additional time taken to teach what those symbols mean to incoming new programmers? If you're supporting unicode and therefore possibly other languages (variables in japanese?), these make another layer of inscrutability. In addition, how useful have you found their logical opposite, the C trigraph ( http://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C )? :-)
Special characters have any place in a modern, non-academic language?
Yes, but because on most desktops the support for special characters is still awful (bad editors, bad fonts, you name it),
I would never advocate a preprocessor: there is too much temptation and room for abuse, and unless it is done very carefully, a preprocessor makes it much harder to write good IDEs and static-analysis tools.
Some people like a postprocessor, i.e., a prettyprinter, that takes sequences of ASCII characters and renders them as something else. While I have always found this style dreadfully confusing, it is quite popular and successful among some Haskell programmers.
I like the idea of using the proper characters a lot. However, in order to use then I would really want a keyboard that had extra punctuation keys to be used for them. And while we're at it, things like { } ( ) " ? + *
should all be on their own keys too.
Not sure about a general purpose language, but these have a place in a DSL for a domain where they're sensible. And it can certainly be done in some modern languages. For an example in Scala, see this blog post.
The special characters ←
and ⇒
are reserved words in Scala. ←
is used for introducing generator bindings whereas ⇒
is used in the function definitions to separate parameter lists from the function body.
Examples:
for {
word ← List("Hello", "World")
character ← word
} println(character)
val square = (x: Int) ⇒ x * x
It should be noted that Scala compiler also allows the ASCII alternatives of the above symbols (i.e. <-
and =>
).
The one language I've used that relies on non-ASCII characters is TI-BASIC, which uses →
for assignment, ≤
/≠
/≥
for comparison, has built-in constants π
and ℯ
, a √
function, etc.
On the PC, I doubt that'd I'd use non-ASCII operators much, simply because it's so much quicker to type !=
than it is to look up ≠
in character map.
Isabelle (the theorem prover) allows LaTeX-style command sequences as valid inputs. Various front-ends then do appropriate things to turn these into special characters. The nice result of this is that it's still just vanilla ASCII text, but you can have all the nice pretty display characters looking as you expect in an editor that is aware of those characters.