Can you introspect predicate arity and if it's an equality predicate?
Seb
seb at wilzba.ch
Fri Jan 12 16:42:02 UTC 2018
On Friday, 12 January 2018 at 13:04:30 UTC, aliak wrote:
> On Friday, 12 January 2018 at 10:55:53 UTC, Seb wrote:
>> On Friday, 12 January 2018 at 00:16:07 UTC, aliak wrote:
>>> Hi, so basically is there a way to:
>>>
>>> void func(alias pred = null, Range)(Range range) {
>>> // 1) check if pred(ElementType!Range.init,
>>> ElementType!Range.init) is equality
>>> // 2) check if isUnary!pred
>>> // 3) check if isBinary!pred
>>> }
>>>
>>> [...]
>>
>> It isn't possible yet, but will be very soon:
>> https://github.com/dlang/dmd/pull/7484
>
> Thats to compare whether lambdaA == lambdaB right? Not if
> lambda(a, b) == lambda(b, a) == true <- i guess this is not
> possible anyway without knowing the entire set of inputs)
Yes. The implementation is actually pretty straight-forward:
Serialize to AST and compare.
More information about the Digitalmars-d-learn
mailing list