Read files at compile time
Henrik
zodiachus at gmail.com
Thu May 31 03:24:16 PDT 2007
Robert Fraser Wrote:
> Hi Henrik,
>
> Check out http://www.digitalmars.com/d/expression.html#ImportExpression , which can read files in as compile-time string literals. You'd then need to write a CTFE-compliant string-splitting function and mix that back in. So, you'd have:
>
> mixin(ctfe_split("archetypes", import("file.txt")));
>
> Which should become something like:
>
> char[][3] archetypes = [ "foo", "bar", "baz", ];
Looks like it could be messy, but worth a try :)
There's not a lot of static information that I want to embed at the moment, but there will be more in the future. It would be nice to be able to avoid large chunks of embedded text/data in the source code by appending it at compile time.
More information about the Digitalmars-d-learn
mailing list