January 14

On Friday, 14 January 2022 at 22:48:42 UTC, Guillaume Piolat wrote:

>

I don't think it's a valid criticism actually.
Not too many objects actually need to be all of the following: hashable, ordered, have a string representation, need ==.

If they need all 4, and they need it virtually, then pay the bytes.

In order to make a class work with associative arrays / hash tables, it will need to implement at least Hash and Equals. Similarly, any class that implements Ordered can and probably should implement Equals, too.

At the very least, Hash and Ordered should both extend Equals so that implementers don't have to waste another pointer on explicitly implementing Equals when it can be done implicitly just as well.

January 14
On Friday, 14 January 2022 at 23:08:29 UTC, Guillaume Piolat wrote:
> not only none of my code breaks (!!!)

How many calls to synchronized(this) do you have in your code base right now?
January 14
On Friday, 14 January 2022 at 22:45:53 UTC, Alexandru Ermicioi wrote:
> Imho interfaces could be smth like this:
>
> ```d
> interface Equals(U) {
>   bool equals(U other);


No const?

Note that opEquals like this already works on dmd master with the specific class and attributes.
January 14
On Friday, 14 January 2022 at 19:22:59 UTC, H. S. Teoh wrote:
> Now you're just splitting hairs.  Number types in a *programming language* (we're not talking about abstract mathematics here) are inherently-ordered types.  This is why `1 < 2` always evaluates to true, and `2 < 1` always evaluates to false in D. ass by which its instances should be ordered

Yet x < x+1 does not hold for any types in D. So much for ordering principles...
January 15
On Friday, 14 January 2022 at 23:51:37 UTC, Ola Fosheim Grøstad wrote:
> Yet x < x+1 does not hold for any types in D.

Huh?  Please expound.  Pretty sure x < x+1 for plenty of types in D, or I'm sure I would have noticed by now!

January 15
On Saturday, 15 January 2022 at 00:09:38 UTC, Greg Strong wrote:
> Huh?  Please expound.  Pretty sure x < x+1 for plenty of types in D, or I'm sure I would have noticed by now!

Consider the case of int.max + 1....
January 15
On Saturday, 15 January 2022 at 00:34:03 UTC, Adam Ruppe wrote:
> On Saturday, 15 January 2022 at 00:09:38 UTC, Greg Strong wrote:
>> Huh?  Please expound.  Pretty sure x < x+1 for plenty of types in D, or I'm sure I would have noticed by now!
>
> Consider the case of int.max + 1....

Ok, fair enough, but given that that issue applies to, like, almost every integer format in, like, every programming language, I just assumed Ola was rather referring to some D-specific problem.  If this is indeed the issue to which he was referring, well, that's just trolling :D

January 15

On Friday, 14 January 2022 at 23:24:07 UTC, tsbockman wrote:

>

On Friday, 14 January 2022 at 22:48:42 UTC, Guillaume Piolat wrote:

>

I don't think it's a valid criticism actually.
Not too many objects actually need to be all of the following: hashable, ordered, have a string representation, need ==.

If they need all 4, and they need it virtually, then pay the bytes.

In order to make a class work with associative arrays / hash tables, it will need to implement at least Hash and Equals. Similarly, any class that implements Ordered can and probably should implement Equals, too.

Or, we templatize the AA implementation and have it call the toHash and opEquals methods of the keys' static type. No need for interfaces, and we can get rid of the dependency on TypeInfo too while we're at it.

January 14
On Sat, Jan 15, 2022 at 12:56:46AM +0000, Greg Strong via Digitalmars-d wrote:
> On Saturday, 15 January 2022 at 00:34:03 UTC, Adam Ruppe wrote:
> > On Saturday, 15 January 2022 at 00:09:38 UTC, Greg Strong wrote:
> > > Huh?  Please expound.  Pretty sure x < x+1 for plenty of types in D, or I'm sure I would have noticed by now!
> > 
> > Consider the case of int.max + 1....
> 
> Ok, fair enough, but given that that issue applies to, like, almost every integer format in, like, every programming language, I just assumed Ola was rather referring to some D-specific problem.  If this is indeed the issue to which he was referring, well, that's just trolling :D

Walter has killfiled certain people on the forums precisely for this reason.


T

-- 
Talk is cheap. Whining is actually free. -- Lars Wirzenius
January 15
On Friday, 14 January 2022 at 23:51:37 UTC, Ola Fosheim Grøstad wrote:
> Yet x < x+1 does not hold for any types in D. So much for ordering principles...

Hm, we do have !(x > x+1) for floats...
1 2 3 4 5 6 7 8 9