CompileTime performance measurement
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 3 18:53:21 PDT 2016
On Sunday, 4 September 2016 at 01:44:40 UTC, sarn wrote:
> On Sunday, 4 September 2016 at 00:04:16 UTC, Stefan Koch wrote:
>> I recently implemented __ctfeWriteln.
>
> Sounds like pragma msg. How does it compare?
> https://dlang.org/spec/pragma.html#msg
Pragma msg can only print compiletime constants.
While __ctfeWriteln can print state while doing CTFE.
Example
int fn(int n)
{
import std.conv;
__ctfeWriteln((n-10).to!string);
return n;
}
static assert(fn(22));
will print 12;
whereas
int fn(int n)
{
import std.conv;
pragma(msg, n.to!string);
return n;
}
will tell you that the symbol n is not avilable at compiletime
More information about the Digitalmars-d
mailing list