Re: interface opEquals

2023-11-27 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 27 November 2023 at 09:53:48 UTC, Antonio wrote: ...but why? All classes (and interfaces I think), at root of inheritance have `Object` class, this class defines couple of generic methods, you can find this class in object.d btw. One of those methods is `bool opEquals(const

Re: interface opEquals

2023-11-27 Thread Antonio via Digitalmars-d-learn
On Saturday, 25 November 2023 at 01:15:34 UTC, Alexandru Ermicioi wrote: On Friday, 24 November 2023 at 17:39:10 UTC, Antonio wrote: ... Dunno if this might help, but I noticed that `==` sometimes calls `opEquals(const Object) const` instead of overload defined on class/interface, you might

Re: interface opEquals

2023-11-24 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 24 November 2023 at 17:39:10 UTC, Antonio wrote: ... Dunno if this might help, but I noticed that `==` sometimes calls `opEquals(const Object) const` instead of overload defined on class/interface, you might try and override it as well, and delegate to your overload that deals

Re: interface opEquals

2023-11-24 Thread Antonio via Digitalmars-d-learn
On Thursday, 23 November 2023 at 21:52:56 UTC, Jonathan M Davis wrote: I'd have to take the time to study your code in detail to see whether what exactly you're seeing makes sense or not ... My apologies... I should have proposed a more specific example. ```d interface IOpt { bool

Re: interface opEquals

2023-11-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 23, 2023 2:20:25 PM MST Antonio via Digitalmars-d-learn wrote: > * Why, when applied to interface, ```opEquals``` called directly > behavior is not the same that when calling ```==``` ? > > * Is it the expected behaviour? I'd have to take the time to stu

interface opEquals

2023-11-23 Thread Antonio via Digitalmars-d-learn
quot;extrange effects" I test an alternative equality that fails too: ```d assert( (cast (IOpt!int) new None!int) == (cast (IOpt!int) new None!int)); ``` What seems strange to me is that ```none!int.opEquals(none!int)``` works properly. **Questions** * Why, when applied to in