program for building the program
gzp
galap at freemail.hu
Tue Dec 1 07:38:53 PST 2009
> "Gzp" <galap at freemail.hu> wrote in message
> news:hf2k9a$2l54$1 at digitalmars.com...
>> So to designing template(generic) code, a simplified language should be
>> created that generates the actual source. So the border b/n the two
>> language can be made more explicit and fewer questions arose.
>>
>
> The problem with that, aside from the increase in the grammar's complexity,
> is that anytime you want to be able to do something at both runtime and
> compile-time, you'd have to write two separate implementations of the same
> thing, which carries with it all the problems assisiated with breaking DRY.
> Plus then that would create a need to write meta-meta-functions that
> generate both the runtime and compile-time versions of the same function.
> CTFE (and better yet, Nemerle's way, at least from what I've seen of it), is
> just a better approach.
OK, CTFE is an optimization question for me. It is not the template,
mixin part of the language. This meta-programming let's you to generates
codes where you'd use cut/past/replace in a much safer, cleaner way.
In CTFE you can give hints to the compiler: hey, please evaluate this
piece of code and substitute only the result. Like in Clean (fully
functional programming language) the actual calculation takes place in
the compiler as much as it can.
And no, I would not allow CTFE codes to be present in the first layer
(as expression to be evaluated).
The compiled program in Clean for printing the first 100 digit of PI
writes out just a string(number) and performs no calculation (in theory,
but I'm not sure what's going on in practice, I haven't written that
much Clean code).
>
>> The compiler also should provide readably output of the generated code.
>
> I'm not sure if this is what you mean, but I definitely want a compiler
> switch that outputs the resulting D code after all the mixins and such are
> applied.
>
>
Gzp
More information about the Digitalmars-d
mailing list