CTFE question

Danny Arends Danny.Arends at gmail.com
Tue Aug 28 04:39:19 PDT 2012


Ahhh I understand...

As a follow up, is it then possible to 'track' filling a
large enum / immutable on compile time by outputting a msg
every for ?

I'm generating rotation matrices for yaw, pitch and roll
at compile time which can take a long time depending on
how fine grained I create them.

Gr,
Danny Arends
http://www.dannyarends.nl

On Tuesday, 28 August 2012 at 11:29:32 UTC, Chris Cain wrote:
> On Tuesday, 28 August 2012 at 11:13:40 UTC, Danny Arends wrote:
>> Is this a bug or am I doing something wrong ??
>>
>> Danny Arends
>> http://www.dannyarends.nl
>
> You're doing something wrong, but I can see why the error 
> message would confuse you.
>
> Your problem is using those pragma(msg, ...) lines... They 
> produce a message while something is being compiled, right? The 
> CTFE function is ran _after_ it has been compiled. Hence i 
> can't be read while the CTFE function is compiled.
>
> So, to be clear, doing this:
>
>
> -----
>
> import std.stdio;
> import std.metastrings;
>
> pure int[] testCTFE(){
>   int[] r;
>   pragma(msg, "Testing CTFE");
>   foreach(i; 0 .. 360){
>     r ~= i;
>     //pragma(msg, Format!("Loop: %d",i));
>   }
>   pragma(msg, "Done CTFE test");
>   return r;
> }
>
> immutable CTFEdata = testCTFE();
> immutable CTFEdata2 = testCTFE();
>
> void main(string[] args){ }
>
> ----
>
> Produces just one output:
> Testing CTFE
> Done CTFE test
>
>
> Because the pragmas are done _as it's compiled_, not as it's 
> ran (even though CTFE is done "at compile time").




More information about the Digitalmars-d-learn mailing list