static map as a type function
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.com
Thu Sep 24 14:10:28 UTC 2020
On 9/24/20 1:51 AM, H. S. Teoh wrote:
> On Thu, Sep 24, 2020 at 01:13:49AM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
> [...]
>> Was looking at this example thinking, if only we had an object
>> available for each type. And then it struck me - we already do. It's
>> typeid. For each type T, typeid(T) yields an object (of type class
>> TypeInfo) that can be copied, compared etc.
>
> +1. I've mentioned this before in one of Stefan's threads. Basically,
> to promote types to first-class citizen status, all we need to do is to
> treat typeid specially at compile-time. At compile-time, typeid becomes
> something like a glorified alias to the type itself, such that it can be
> manipulated, passed around, interrogated, etc.. At runtime, typeid
> becomes the familiar RTTI object.
Indeed you did!
https://forum.dlang.org/post/mailman.5271.1597852264.31109.digitalmars-d@puremagic.com
> [...]
>> * This could work with no change to the language definition. All
>> that's needed to get lift is make TypeInfo values usable during
>> compilation.
>
> Or treat typeid specially at compile-time, as a compile-time object not
> necessarily tied to TypeInfo (but "collapses" into TypeInfo at runtime).
Looks like we have something here!
More information about the Digitalmars-d
mailing list