Reimplementing the bulk of std.meta iteratively

Steven Schveighoffer schveiguy at gmail.com
Sat Sep 26 22:15:09 UTC 2020


On 9/26/20 6:03 PM, Andrei Alexandrescu wrote:
> On 9/26/20 6:00 PM, Steven Schveighoffer wrote:
>> On 9/26/20 5:42 PM, Andrei Alexandrescu wrote:
>>> On 9/26/20 5:16 PM, Timon Gehr wrote:
>>>> On 26.09.20 18:18, Andrei Alexandrescu wrote:
>> Such things are not *impossible*, but something like derivative is a 
>> great example that is really difficult to generate a runtime function 
>> that can do it.
> 
> Yah, you'd need i.e. a member function in Id called bool 
> implicitlyConvertible(Id another). The functionality needed is similar 
> to that in Variant, which created the need for implicitConversionTargets 
> (https://dlang.org/library/std/traits/implicit_conversion_targets.html). 
> You'd need to have access to those in the Id space.

Variant works because it can access the parameter type. If you need to 
access only one type, and the other information is runtime-accessible, 
then you can do it. If both need to be runtime-accessible, you are in 
trouble.

Like try comparing 2 Variants. If Variant doesn't have any idea about 
how the types might compare ahead of time, it gives up.

-Steve


More information about the Digitalmars-d mailing list