RT/CT Type
Jacob Carlborg
doob at me.com
Tue Apr 2 10:45:37 UTC 2019
On 2019-04-02 09:48, Alex wrote:
> 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.
I would much rather that D had first class types. That is, it would be
possible to store types in variables and in arrays and so on.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list