DIP 50 - AST macros

Jacob Carlborg doob at me.com
Mon Nov 11 00:49:23 PST 2013


On 2013-11-11 09:28, simendsjo wrote:

> I agree examples would help a lot. Trying to define what information
> actually exists within these types would also help a lot.

I can tell you right now that I haven't figured out everything, far from 
everything.

> In the first example, would Ast!(bool) be something like this?
>    opBinary!"=="
>      left = opBinary!"+"
>               left = Literal
>                 type = int
>                 value = 1
>               right = Literal
>                 type = int
>                 value = 2
>      right = Literal
>        type = int
>        value = 4
>
> Would there be helpers for matching part of the structure?

I don't know. As I said above, I haven't figured out everything. I don't 
see any support for this in the language. But of course, there can be 
library functions that help with this.

> The same applies to the other types used - what information should they
> have?

Suggestions are welcome. Also, see my reply to bearophile

http://forum.dlang.org/thread/l5otb1$1dhi$1@digitalmars.com#post-l5q1p5:242bs4:241:40digitalmars.com

> As for examples, here's a couple of suggestions:
> * Expression to prefix notation
> * Expression to SQL
> * AutoImplement properties (like C#)

Would that be something like the attribute macro example?

http://wiki.dlang.org/DIP50#Attribute_macros

> * Number intervals, like "int i = int[10..20];" where only 10 to 20 are
> legal values
> * Discriminated union
> * Pattern matching

Pattern matching usually requires new syntax, which this proposal does 
not support.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list