Reimplementing the bulk of std.meta iteratively

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Sep 26 16:40:47 UTC 2020


On Sat, Sep 26, 2020 at 12:18:27PM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
[...]
> The implementation uses throughout a reification/dereification
> approach. To reify a type or alias means to convert it into a value.
> To dereify a value means to turn it back into the type or alias it
> originated from.
[...]
> Its weakest point is it uses .stringof for types, which has issues
> with local types. Hopefully https://github.com/dlang/dmd/pull/11797
> could help with that.
[...]

This is awesome!  I think dmd pull #11797 is the best way forward from
our current state.  It closes the reification/dereification loop, and
allows CTFE manipulation of types as strings, which sidesteps the issues
of how to manipulate types in imperative code without running into all
sorts of problems like the ones that Stefan brought up.

In the future, I can imagine CTFE *generation* of these strings, which
opens up brand new ways of manipulating types.  There could be a
standard set of mangle-string manipulation utilities in druntime or
phobos, say, that let you perform operations like adding/removing
qualifiers, manipulating type lists (in string form!), so you could
implement things like Unqual as a CTFE string manipulation function
instead of a bunch of templates. Of course, Unqual is simple enough that
there's no reason to do this, but the point is, we can do much more
complicated manipulations of types without needing to resort to
recursive templates, and it leverages existing machinery instead of
inventing a slew of new ones.


T

-- 
LINUX = Lousy Interface for Nefarious Unix Xenophobes.


More information about the Digitalmars-d mailing list