-
Notifications
You must be signed in to change notification settings - Fork 6
Split eq
out of Ord
and put it in Eq
.
#8
Comments
|
Already have a small path on my Fork, still testing to ensure it's non-breaking |
@otrho would you also want a patch to give booleans the Eq trait so they can be compared using an "eq" function? |
Yes, that makes sense. Ideally in a separate PR from splitting up |
Working with a new approach atm, as moving Eq breaks some of Ord's ge, le, neq methods. So to fix this I've changed how some of those functions work to a pure assembly implementation rather than relying on function calls to a specific eq method |
Yep, OK, I don't think it's possible to do this 'properly' at the moment since we need 'Supertraits'. e.g.,
I was hoping initially that we could skirt around it, but it doesn't seem possible. The only alternative, as @ControlCplusControlV has hinted at, is to implement Does this sound right to you @sezna? |
@otrho I actually remembered a mistake Fuel made in Yul+, and I am determined to not let it happen again! Yul+ initially implemented the way Sway has right now
|
So implementing along the lines of would be the best way. Will work on a patch and test tomorrow
|
Is there a case where Edit: answered my own question: https://doc.rust-lang.org/stable/src/core/cmp.rs.html#432 @ControlCplusControlV Just like the above in Rust, instead of implementing |
@adlerjohn I can try to test, the issue we were running into is the implementation of le and ge would have to require the implementation of lt, eq, and not which it currently can't atm |
Ah right. Then as a temporary workaround, sure re-implementing these simple functions is probably fine. |
The point of having the default implementations in a trait, as It's preferable to leave micro-optimisations, such as using BUT! This is all in an ideal world, of course. Sway isn't quite there yet, but we really want it to get there eventually, so it's good to think in terms of the ideal situation. Perhaps a compromise, until we have the ability to use 'supertraits', we could just literally use |
The canonical example I think of is floats and |
And if we don't have |
|
Ahh, chicken and egg in |
Yep, this is exactly why |
Just curious if this is still moving forward or on hold for now. |
If this is needed for a temporary solution I can get one done in a couple of hours, was placed on a bit of hold since a proper implementation wasn't available atm, but will whip out a quick asm implementation |
Fixed in #9 should be good once that is merged |
We should close this issue |
We need
eq
forbool
, butlt
andgt
don't make sense for bool, so I think we need anEq
trait foreq
.The text was updated successfully, but these errors were encountered: