Operator overloading -- lets collect some use cases

Jarrett Billingsley jarrett.billingsley at gmail.com
Sun Dec 28 15:46:40 PST 2008


On Sun, Dec 28, 2008 at 6:14 PM, Yigal Chripun <yigal100 at gmail.com> wrote:
>
> could you please elaborate on this, and/or provide a code example?

Don's Blade library is more or less a proof of concept for what I
would imagine to be possible with macros:

http://www.dsource.org/projects/mathextra/browser/trunk/blade

His library works by having you write your code in a DSL in strings,
which you pass to the library and then mix in the resulting X86.

http://www.dsource.org/projects/mathextra/browser/trunk/blade/BladeDemo.d

If we had AST macros, the parsing would be performed by the compiler
instead of hackishly using CTFE and templates, and the library would
just be concerned with matching certain patterns of expressions,
performing transforms on them (simplifications, optimizations, etc.),
and turning them into D code.

String mixins are incredibly powerful.  But they're powerful in the
way that assembly language is powerful - you can do anything, but
there are virtually no useful abstractions provided, so you end up
having to do everything yourself - parsing, pattern matching, etc.



More information about the Digitalmars-d mailing list