static code generation
js.mdnq
js_adddot+mdng at gmail.com
Sun Dec 9 02:45:08 PST 2012
On Sunday, 9 December 2012 at 10:42:40 UTC, js.mdnq wrote:
> How can I create mixes of stringified code and code itself?
>
> http://dlang.org/mixin.html
>
> explains how to create structs using strings. But what if I do
> not want to have to encode the whole struct as a string but
> only parts of it?
>
>
> mixin template GenStruct(stringname)
> {
> struct stringname ~ "alpha"
> {
> ....
> }
> }
>
>
> mixin GenStruct!("Helpme");
>
> would be equivalent to do the following
>
> struct Helpmealpha
> {
> ....
> }
I do realize I can probably do this by importing a file into a
string but I do not want a ton of little files floating around to
try and manage something relatively simple.
More information about the Digitalmars-d-learn
mailing list