Reimplementing the bulk of std.meta iteratively

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Sep 26 22:48:45 UTC 2020


On 9/26/20 6:15 PM, Steven Schveighoffer wrote:
> 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.

A possibly angle here is to save that information in runtime format, 
i.e. reify the inheritance/convertibility relationship. I'm unclear on 
how to do that efficiently. (The inefficient solution would save the 
result of ImplicitConversionTargets in a member of Id that has type Id[] 
and then do searches in it.)

In an ideal world it would be nice if id1 <= id2 iff is(reify!id1 : 
reify!id2).


More information about the Digitalmars-d mailing list