crazy tuple ideas.
BCS
BCS at pathlink.com
Fri Mar 2 11:16:06 PST 2007
Knud Soerensen wrote:
> With people starting to write compiler time parsers,
> maybe it would be a good idea to have a standard way for
> representing syntax trees.
>
> By allowing tuples to contain tuples we will have something
> very similar to the lisp list expression.
There's nothing crazy about that. <g>
> Example:
> Tuple!(=,E,Tuple!(*,m,Tuple!(^,c,2))); // E=m*c^2;
> or maybe allowing the programmer to write just
> (=,E,(*,m,(^,c,2)))
Um, I'm not so sure about that syntax...
>
> By using a standard way for representing syntax trees
> we allow for more code sharing between project which
> uses them.
vote++
>
> Also if the D compiler made the programs syntax tree
> available doing compilation if would be possible to make
> modules which could modify the programs syntax tree at compiler time.
That could make for some nasty debugging, going with a "here's some AST,
build it" would do lots and not be so nasty. Even allowing for AST
literals would do a lot without being quite as hard to work with.
This
template foo(A...){...}
foo!(a+bc/d, i+jk*f);
ends up like:
foo!(Tuple!(a, +, Tuple!(bc, /, d)), Tuple!(i, +, Tuple!(jk, *, f)));
with the IDs being aliases and the ops being something somewhat like a
type (compile time only symbol).
More information about the Digitalmars-d
mailing list