What type functions mean on a language level

Stefan Koch uplink.coder at googlemail.com
Sun Jan 3 14:17:38 UTC 2021


On Sunday, 3 January 2021 at 14:05:21 UTC, sighoya wrote:
> On Saturday, 2 January 2021 at 22:47:29 UTC, Stefan Koch wrote:
>> You can use typeid at compiletime.
>> I know because I implemented it.
>
> ```
>
> void main()
> {
>     import std.algorithm, std.stdio, std.file, std.range;
>     static assert(typeid(int)==typeid(float));
> }
>
> onlineapp.d(4): Error: static variable typeid(int) cannot be 
> read at compile time
> onlineapp.d(4):        called from here: opEquals(typeid(int), 
> typeid(float))
> onlineapp.d(4):        while evaluating: static 
> assert(typeid(int) == typeid(float))
>
> ```
>
> Or did you mean you have implemented it in your newCTFE branch?

No, I did not mean that.
But the support for typeid in CTFE is not very solid at the 
moment.
Perhaps you can only access certain properties of typeid.
The reason being that you cannot generate an actual TypeInfo 
hence the compiler has to fake  it.


More information about the Digitalmars-d mailing list