Reimplementing the bulk of std.meta iteratively

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Sep 30 23:36:31 UTC 2020


On Thu, Oct 01, 2020 at 01:17:27AM +0200, Timon Gehr via Digitalmars-d wrote:
> On 29.09.20 01:37, Stefan Koch wrote:
[...]
> > That's true. At least as it stands right now.
> > I _could_ give  the alias a physical form at runtime.
> > (By doing the same thing that the reify template does (or rather
> > will eventually do), that is exporting _all_ the properties of the
> > type into an object)
> > 
> > However I am not actually sure what the use of this would be.
> > All usage that I have seen, is in generating code, which is kindof
> > useless if it does not happen at compile time.
> > 
> > Perhaps there are others?
> 
> It's not a first-class type if you can't declare a variable of that
> type. If this does not work, it's not first-class, it's syntax sugar
> for reification:
> 
> type t = int;
> auto f = (t x)=>x;

I think there's a lot of value to be had in making typeid(T) as the
reification of T.  At compile-time, we treat it specially by augmenting
it with the ability to do things that can only be done at compile-time,
such as recover T given typeid(T) (pass it into a template parameter,
construct new types out of it, etc.). At runtime, it reverts to the
current behaviour of typeid(T).

Only trouble is, according to Andrei, typeid has been written over so
many times that even Walter doesn't understand how it works anymore.
Meaning there are probably weird corner cases and quirky behaviours that
we may not want to duplicate at compile-time. So I dunno, this seems
like a roadblock to further progress.  (It really makes one wish for a
gradual transition to D3 where we can correct such deeply-rooted flaws
that may otherwise be uncorrectible.)


T

-- 
To provoke is to call someone stupid; to argue is to call each other stupid.


More information about the Digitalmars-d mailing list