On 1/23/13 2:28 AM, Jacob Carlborg wrote:
On 2013-01-22 20:51, Andrei Alexandrescu wrote:

Not at all, I'd say. CTFE has a much lower cost of learning - you only
need to know which subset of D is allowed. Maybe you meant code mixins?

To be able to use AST macros one needs CTFE. One needs functions to
manipulate the AST during compile time. As far as I understand it, in
Scala they just create a new instance of the compiler, during
compilation, and just like that they have access to the whole language
during compilation.

Martin Odersky confessed to me being quite worried about the possible community reaction to the introduction of AST macros. I haven't kept close tabs to see how it's turning out.

In D it feels like a feature first need to be implemented in the regular
compiler. Then it needs to be duplicated to be able to be used as CTFE.

Example, in Scala if you throw an exception during compile time it will
be handled properly and generate a compile error. What happens if you do
the same in D? It won't run the function during compile time?

Techincally you can generate an empty AST just to be able to run a bunch
of functions during compile time. This would be no higher cost of
learning than CTFE in D.

I completely disagree. (Sorry to foul you twice.) All AST macro systems I've studied are considerably difficult to understand and use effectively. By comparison, string macros are brutal and unstructured but the kind of thing all programmer worth their salt can get done.


Andrei

Reply via email to