Reimplementing the bulk of std.meta iteratively
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Thu Oct 1 18:51:04 UTC 2020
On Thursday, 1 October 2020 at 08:59:04 UTC, Walter Bright wrote:
> On 10/1/2020 12:51 AM, Timon Gehr wrote:
>> Maybe this is related to what you mean?
>>
>> type t = readln().strip()=="int"?int:double;
>> auto f = (t x)=>x;
>
>
> As D is a statically typed language, I don't see how that can
> ever work.
Flow analysis. You can deduce that t can only be int|double at
the second line and then expand the code into a switch over the
type (encoded as enum values).
It cannot work with separate compilation though.
More information about the Digitalmars-d
mailing list