recursive equal, and firstDifference functions

John Colvin john.loughran.colvin at gmail.com
Tue Mar 19 05:36:33 PDT 2013


On Tuesday, 19 March 2013 at 12:34:04 UTC, monarch_dodra wrote:
> On Tuesday, 19 March 2013 at 12:11:50 UTC, bearophile wrote:
>> Jonathan M Davis:
>>
>>> Going beyond a range of ranges is likely to be quite rare,
>>
>> I agree.
>>
>>
>>> and when it does happen, you can simply nest equal as many 
>>> times as you need.
>>
>> A similar function seems useful for Phobos because it's 
>> automatic, you don't need to tell it how many levels there are.
>>
>> Bye,
>> bearophile
>
> But the compiler can't tell how many levels deep you want to 
> go. There are legitimate cases of "Range of Stuff" where Stuff 
> just so happens to be a range, but you don't want range 
> comparison.
>
> For example:
> class MyClassRange;
>
> MyClassRange a, b;
>
> SuperEqual(a, b); //?
>
> I think using equal!equal is not that much more verbose, but 
> safer/explicit.

I think if your calling a recursive version of equal, then you 
assume it will go as deep as possible. If you want control as to 
how deep, then you can either use equal manually, or there could 
be a maximum depth parameter to the recursive equal.


More information about the Digitalmars-d-learn mailing list