Ancestors

Toot

Written by soc on 2024-08-21 at 15:49

Rust people are so weirdly invested in their Eq/PartialEq mistake that they keep adding new things under it, like StructuralEq/StructuralPartialEq.

Hint: If it worked, you wouldn't need to keep changing it.

[#]rust

=> More informations about this toot | More toots from soc@chaos.social

Descendants

Written by Sebastian Lauwers on 2024-08-21 at 15:55

@soc I’ve been using Rust for nearly a decade and I still have no idea what the hell that was.

=> More informations about this toot | More toots from teotwaki@mastodon.online

Written by soc on 2024-08-28 at 14:30

@teotwaki Some follow-up discussion happened in https://chaos.social/@soc/113027993190371352 fwiw.

=> More informations about this toot | More toots from soc@chaos.social

Written by soc on 2024-08-28 at 14:34

@teotwaki TL;DR: Floats, like many other types, have more than one order.

But in #Rust Eq/PartialEq (and Ord/PartialOrd) are linked, so you have to pick one order, despite technically having two traits available.

=> More informations about this toot | More toots from soc@chaos.social

Written by Ben Kimock on 2024-08-22 at 02:48

@soc What is the mistake?

=> More informations about this toot | More toots from saethlin@hachyderm.io

Written by soc on 2024-08-22 at 11:20

@saethlin Not having a free-standing trait for total order.

Eq being a marker trait subtyping PartialEq is cute ("look, we know math"), but I'm not aware of a single practical application of it, e. g.

"our algorithm is x% faster, because we exploit knowing that type T is not only a PartialEq, but an Eq".

On the downside, we have this inconsistency in the standard library where some collections do not support floating-point values at all, and others accept them but fail at runtime.

=> More informations about this toot | More toots from soc@chaos.social

Written by Ben Kimock on 2024-08-22 at 12:44

@soc Which collections fail at runtime?

=> More informations about this toot | More toots from saethlin@hachyderm.io

Written by soc on 2024-08-22 at 13:06

@saethlin Anything that constrains contains to PartialEq

let nan = 0.0/0.0;

let slc = [nan];

let vec = vec!(nan);

let rng = nan .. nan;

slc.contains(&nan);

vec.contains(&nan);

rng.contains(&nan);

leads to x is not in collection of x for some values of x.

It's fine to have a method for "does this value think that, according to its own domain-specific rules, some value in this collection is equal to itself" – but certainly not as its primary&only lookup function.

=> More informations about this toot | More toots from soc@chaos.social

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113000799023409208
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
290.961243 milliseconds
Gemini-to-HTML Time
1.019802 milliseconds

This content has been proxied by September (3851b).