DMD 1.005 release
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Wed Feb 7 16:26:42 PST 2007
Kyle Furlong wrote:
> Yauheni Akhotnikau wrote:
>> On Wed, 07 Feb 2007 22:18:28 +0300, Walter Bright
>> <newshound at digitalmars.com> wrote:
>>
>>> Yauheni Akhotnikau wrote:
>>>> Do you think this task can be done with D templates at complile time?
>>>
>>> Yes, that's exactly the intent. If this can't be made to work, we'll
>>> fix D so it can.
>>
>> May be I'm wrong, but I think that 'static if' and recursive templates
>> (and other techniques available for metaprogramming at compile time)
>> are not as powerful as ordinary D itself. So it is much more
>> preferable to me to program such DSL as 'normal' D program. May be it
>> is a good idea to make 'staged' compilation? For example DSL
>> transformation code is written as ordinal D programm. Then that code
>> compiled at first compilation stage, then it is invoked by compiler
>> and the result is placed into input to the next stage.
>>
>> Something like that:
>>
>> // active_record.d
>> // DActiveRecord implementation.
>> module active_record;
>>
>> // DSL transformator.
>> char[] DActiveRecord( char[] input ) { ... }
>>
>> ===
>>
>> // demo.d
>> // DActiveRecord usage.
>> module demo;
>>
>> import active_record;
>>
>> // Function DActiveRecord will be called at compile time.
>> mixin( DActiveRecord( "class Account ... end" ) );
>>
>> ===
>>
>> Two points must be highlighted here:
>> * code of DActiveRecord must be used only at complite time and threw
>> out from the resulting application code;
>> * multiple stages must be allowed: for example, DActiveRecord may
>> depend on another DSL and so on.
>>
>> --Regards,
>> Yauheni Akhotnikau
>
> I agree with the point that metaprogramming needs more control structures.
>
> static for, static foreach, static while, static do, static switch case,
> etc.
Static loops are not very useful without compile-time mutation.
Andrei
More information about the Digitalmars-d-announce
mailing list