opMixin or mixin function templates with convenience operator?

Paul Backus snarwin at gmail.com
Fri Dec 13 16:07:01 UTC 2019

On Friday, 13 December 2019 at 15:38:14 UTC, Ola Fosheim Grøstad 
>> I mentioned PARSE and REFILL from Forth, and reader macros from
>> Common Lisp. The age and identifiers of these languages has
>> nothing to do with the capabilities of those features. What
> Well, it kinda does, but regardless. Nobody has stated what AST 
> manipulation in D would look like, so what outdated languages 
> have done isn't really relevant unless someone propose exactly 
> the same.

Walter and Andrei's proposal from 2012 [1] looked like this:

// definition
macro debugPrint(expr) {
     writefln("%s(%s): %s == %s", __FILE__, __LINE__, 
expr.stringof, expr)

// usage
debugPrint(2 + 2);

You'll notice that there's no direct manipulation of the 
AST--everything is done by substitution.

[1] https://www.youtube.com/watch?v=FRfTk44nuWE&t=1h5m37s

More information about the Digitalmars-d mailing list