Compile-time generated code... not that nice

davidl davidl at nospam.org
Sat May 30 21:22:10 PDT 2009


在 Sun, 31 May 2009 05:31:45 +0800,Jarrett Billingsley  
<jarrett.billingsley at gmail.com> 写道:

>
> Oh I certainly don't disagree with you that string mixins make this
> kind of stuff extremely difficult to debug.  It's even difficult for
> the compiler to issue reasonable error messages; currently it seems to
> issue errors within string mixins at (line of mixin expression + line
> within string), which is usually completely bogus.  However, if we're
> going to solve the debugging issues with string mixins, we may as well
> try to find a solution that would improve the handling of templates in
> conjunction with debug info as well.

a possible sulution:

in a file Blah.d:83, we have following
mixin(compile_time_string);

1. write the compile_time_string to file \mixin\Blah\mixin_001.d ( 001 is  
the id ) with the boilerplate: // mixed in file: Blah.d:83 (mixin LoC)
2. the debug info for the compile_time_string all points to that  
\mixin\Blah\mixin_001.d

if we have more strings to be mixed in, we can simply increase the id 001  
to 002, and generate another file into dir \mixin\Blah

For templates we can store them in  
\template\Blah\template_templateName_templateArgs.d


-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list