Adding Unicode operators to D

Yigal Chripun yigal100 at gmail.com
Thu Oct 23 04:41:43 PDT 2008


Andrei Alexandrescu wrote:
> Please vote up before the haters take it down, and discuss:
> 
> http://www.reddit.com/r/programming/comments/78rjk/allowing_unicode_operators_in_d_similarly_to/
> 
> 
> 
> Andrei

A few thoughts on the subject:

- others already mentioned, i think, smalltalk as an example. smalltalk
bundles as part of the language also the complete environment and IDE so
they can add Unicode chars without worrying much about editor support.
in D this is an issue as D doesn't provide an "official" D editor. The
support largely exists for Unicode - even plain notepad supports Unicode
fully but that doesn't mean people are using any of the many editors
that has this feature.

- smalltalk uses left-arrow as assignment op. the way you enter it is by
typing "<_" so this is similar to Bill's suggestion, i.e. define a short
sequence of chars to be replaced by a Unicode char in the file source.

- why not generalize the concept? a few ideas: syntax is not important
here, just the idea itself..
1) bool compare as == (A a, A b) {}
you can add an op alias to your function, maybe define anonymous
function with alias to be used only as op.
2) provide a way to specify which functions can be used as infix
functions (Scala does that IIRC) and maybe even specify precedence
somehow, so that downs' map function could be written as :
infix void map(...) {}
and used as: dg map array;


More information about the Digitalmars-d-announce mailing list