Adding Unicode operators to D

Alix Pexton alixD.TpextonNO at SPAMgmailD.Tcom
Sun Oct 26 03:39:53 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

I've been following this thread without really having an opinion to 
offer, but I just had a thought...

We already know that D's CTFE and templates can be used together to 
parse DSLs (matrix ops, regular expressions and IIRC Scheme too) and 
turn them into optimal native code. That suggests to me that it is 
already possible to write D code that can turn an expression written in 
established mathematic/scientific notation (complete with unicode 
symbols) into either conventional D code, or machine code.

What I am not sure of is whether is would be possible to make it general 
enough to work with all mathmatical dialects (I seem to remember some 
overlapping in ways that might be problematic). A complete solution 
would have to be able to define new operatos (including thier 
associativity and precidence) in such a way that they can be looked up 
by the templates that evaluate the expresion.

Another related thought I had: Would it be possible to write a 
compile-time parser that turned MathML into code? I'm not even sure if 
MathML is structured enough to represent the undelying meaning of an 
expression rather than just its graphical form. Perhaps it would be more 
interesting to write the code that did the tranformation in the opposite 
direction, turning expressions written in D into MathML ^^

A...


More information about the Digitalmars-d-announce mailing list