RT/CT Type

Alex AJ at gmail.com
Tue Apr 2 07:48:23 UTC 2019


Since D has a highly evolved meta programming and it should have 
unitifed type that works two ways:

1. At CT, the type acts as an type or sorta like an alias.
2. At RT the type acts as a string.

Type t = int;

At compile time,

t x;

is the same at

int x;


At RT t = "int"


Why is this important?


The purpose is to unify certain CT and RT code. Because CTFE acts 
as runtime we might use it to build a type, but as a string, such 
as

return getType(T)(T x)
{
     return T.stringof; // CTFE/RT
     //return T // would be simpler
}

But then we could do

getType(32) x;

at CT.

or use getType at runtime.

This is a contrived example but I'm finding that I'm having to 
use CTFE to deal with types which requires strings and then 
convert those strings back in to types using string mixins, which 
is a PIBA.











More information about the Digitalmars-d mailing list