On Thursday, 5 December 2013 at 14:18:46 UTC, Chris Cain wrote:
On Thursday, 5 December 2013 at 09:25:30 UTC, Don wrote:
I think that is of negligible benefit. There's not a whole of
difference between manipulating an AST, vs manipulating text,
and I'm confident that the time taken to do that is always
going to be far more than the time required to lex and parse
text.
What AST macros could provide is syntax sugar.
But IMHO there's a lot more to be gained from improvements to
compile time reflection.
Negligible? AST macros write the front-end of a D compiler for
a string mixin for you. That's not negligible.
What I said was negligible was:
"The advantage of AST macros is that the compiler doesn't need
to re-lex and re-parse the result."
It's a negligible benefit because most of the time is spent in
the semantic pass (which can take unbounded time), not in the
lexing and parsing steps (which always take time O(n), where n is
the length of the source code).
Even if the D frontend was static and didn't change it would be
difficult to reach parity. The best that can be done now is a
language that reminds you of D (or a D subset that, at best,
will confuse users since it's not going to support nearly
everything).
Actually everything can be done in a library. Especially when we
switch to the frontend written in D, the library and compiler
source can be the same.
But I don't see the point of it being identical to D.
Of course, I know we're not going to get AST macros, but at
least don't say things like it's "negligible". The only reason
we aren't getting AST macros is because it's the opposite of
negligible; it's _too powerful_.
Remember that it would have to be "more powerful" than an
arbitrary chunk of source code text. I don't see how that could
possibly be true.