Reimplementing the bulk of std.meta iteratively
Timon Gehr
timon.gehr at gmx.ch
Thu Oct 1 12:52:41 UTC 2020
On 01.10.20 10:56, Walter Bright wrote:
> On 10/1/2020 12:48 AM, Timon Gehr wrote:
>> (In terms of compiler implementation, the runtime representation of
>> `T` would contain all information that is necessary to figure out
>> calling conventions of functions that take a T, it would contain
>> sizeof, pointers to destructor/postblit, etc, so basically it's typeid.)
>
> I had looked into this. Unfortunately, many aspects of types are simply
> too complex to try and represent at run time. For example, is type T1
> implicitly convertible to T2? This seemingly simple question is very
> complex. Yes, `alias this` makes it much worse :-/
> ...
The compiler can figure it out, so you *could* just put that logic into
druntime. However, for first-class types, you don't need to check
implicit conversions at run time, therefore this would not be necessary.
> I initially had high hopes for typeid back when it was originally
> designed 20 years ago. It ably fulfills its original purpose of enabling
> the GC and associative arrays in a language with no templates.
> ...
And a monomorphic type system.
> I don't see much future for it other than being kept around for legacy
> compatibility.
I was explaining conditions for types to be "first-class". So unless
that is a goal, typeid might not see a revival.
More information about the Digitalmars-d
mailing list