RSS Amplifier

soc.me · Jun 9, 2022

Language Design: Equality & Identity – Part 6: Fixing Rust

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

Rust designers recognized the issues with Haskell’s approach, but were not able to address the issues with Rust’s Eq and PartialEq traits. The main cause of this failure is the sub-typing relationship between PartialEq and Eq : It requires that an implementation of partial order is consistent with an implementation of total order. This works for many types, but not for floating point types, for…

Rust designers recognized the issues with Haskell’s approach, but were not able to address the issues with Rust’s Eq and PartialEq traits.

The main cause of this failure is the sub-typing relationship between PartialEq and Eq:

It requires that an implementation of partial order is consistent with an implementation of total order.

This works for many types, but not for floating point types, for which the IEEE754 standard specifies a partial order as well as a total order.

The easiest solution for Rust would have been to not introduce the sub-typing relationship between PartialEq and Eq (as well as between PartialOrd and Ord).

Read on /languages/equality-and-identity-fixing-rust.html

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.