[Issue 1301] CTFE fails for ImportExpressions
Max Samukha
samukha at voliacable.com.removethis
Mon Jul 2 07:41:46 PDT 2007
On Sat, 30 Jun 2007 13:00:44 -0500, Chris Nicholson-Sauls
<ibisbasenji at gmail.com> wrote:
>One thing I think should work is hiding the import() in a template, and
>sending that value off to the CTF.
>
>template T_Import (char[] file) {
> const T_Import = import(file);
>}
>
>template T_Foo (char[] file) {
> const T_Foo = `foo("`~T_Import!(file)~`")` ;
>}
>
>char[] foo (char[] data) {
> // ...
>}
>
>void main (char[][] args) {
> mixin(T_Foo!("template"));
>}
>
>I've used something similar to preload image and font data in an SDL
>based program. It does work -- and the extra T_Import template
>maintains one copy of a given file being embedded. (Otherwise fonts at
>least would sometimes result in two or three copies. Bad bad disc
>usage, that.)
>
>-- Chris Nicholson-Sauls
Thanks for the idea.
More information about the Digitalmars-d-bugs
mailing list