CTFE - compiling other languages inside D

David Nadlinger see at klickverbot.at
Wed Aug 10 15:07:55 PDT 2011


On 8/10/11 11:43 PM, Marco Leise wrote:
> Am 10.08.2011, 22:49 Uhr, schrieb Timon Gehr <timon.gehr at gmx.ch>:
>
>> Marco Leise wrote:
>>> For starters, how about this?:
>>> static string someExternalText = __ctfeReadFile("external.txt");
>>> static byte[] chipInitialState = __ctfeReadFile("initial_state.bin");
>>
>> static string someExternalText = import("external.txt");
>> static byte[] chipInitialState = import("initial_state.bin");
>>
>> (You need to pass the -Jpath switch)
>
> Oh err, well. I was a little behind time it seems *g*.
> So Ary Manzana was wrong saying "I think it's possible, though CTFE
> can't access outside resources."

Well, you can't really use import() from CTFE, the file name must be a 
compile-time constant. This would make things like importing other files 
based on include statements in some file cumbersome, as you would have 
to resort to a strange combination of templates and CTFE.

David


More information about the Digitalmars-d mailing list