Are we on the simplest path for working with compile time entities?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.com
Fri Sep 25 15:25:16 UTC 2020
On 9/25/20 5:37 AM, Stefan Koch wrote:
> Hi,
>
> If you'll remember I recently talked about an alternative way of
> implementing working with compile time entities such as types.
>
> And I was pleased about it getting attention from prominent forum
> members and even Walter.
>
> I gave the example of using a static map function to get the type sizes
> of a tuple of types.
>
> As a result Walters does adds the ability to get sizeof without having
> to interface with the type entities :
> The code for just that functionality to be added is this:
>
> if (fd.ident == Id.tsize)
> {
> // Equivalent logic to `T.sizeof` in
> getProperty()
> d_uns64 sz = t.size(dve.loc);
> if (sz != SIZE_INVALID)
> {
> ret = new IntegerExp(dve.loc, sz,
> Type.tsize_t);
> return;
> }
> }
Reference: https://github.com/dlang/dmd/pull/11792
This is a small-cost and small-impact change. It's very rare the size
gets used with any frequency during compilation. A small step that is
somewhat lateral.
The prize is https://issues.dlang.org/show_bug.cgi?id=9945.
I also added what is an obviously simpler way to go about things. It's
not like a type changes size and alignment during the program:
https://issues.dlang.org/show_bug.cgi?id=21276
More related stuff:
https://issues.dlang.org/show_bug.cgi?id=21277
https://issues.dlang.org/show_bug.cgi?id=21278
More information about the Digitalmars-d
mailing list