Writing/Creating files at compile-time
Rikki Cattermole via Digitalmars-d
digitalmars-d at puremagic.com
Sun Aug 9 07:50:19 PDT 2015
On 10/08/2015 2:38 a.m., jmh530 wrote:
> On Sunday, 9 August 2015 at 14:00:55 UTC, Rikki Cattermole wrote:
>>
>> I'm actually at the point where I believe the addition of string
>> import was a bad one. No. I prefer preprocessing into a D file first.
>> It irks me, you have to be pretty careful with them, but at least a
>> preprocessed file you know _exactly_ where all files need to be for CT.
>
> Could you provide an example of your point about being careful with D's
> imports? I'm not sure I've had this problem.
1. The biggest issue is actually a bug. With subdirectories not working
on Windows. Yes, bug but a BIG problem.
2. They promote using them all over the place, when in reality with CTFE
you shouldn't. You should be very careful when you initiate these sort
of things. E.g. Do it in one are of the program so you don't have to
grep to find where they are declared.
But alas, most of it is just intuition. I don't think it'll play well if
you do anything crazy. But hey I'm the only one that does that sort of
thing so no worries there ;)
On that note, when I began working on Developing with compile time in
mind[0], string imports didn't exist. So I should really add a bit about
that.
> I'm happy to admit I like D's imports, especially compared with C++. Is
> your ideal alternative something like C's processor or something else?
Bin2D[1] is my preferred processor. Note, I'm the author.
Pros:
- Typically these resources are long lived, so files that contain the
contents are just as viable
- Can work for any asset files
- Can take in directories and even sub directories
- Can export once program started
- Usable at runtime and compile time
Cons:
- Larger input files ~2-3 larger
- Required to run as a preprocessor over input files
[0] https://leanpub.com/ctfe
[1] https://github.com/rikkimax/Bin2D
More information about the Digitalmars-d
mailing list