Stream: beginners

Topic: equality checks


view this post on Zulip Georges Boris (Apr 27 2023 at 11:06):

folks, just out of curiosity, how does equality checks work in Roc? does in-place mutation affects that in any way? (maybe this question is more of a dummy question related to any immutable languages but hopefully I can nerdsnipe someone to explain it a bit :grinning_face_with_smiling_eyes:)

view this post on Zulip Folkert de Vries (Apr 27 2023 at 11:16):

kind of maybe? we have less sharing than e.g. elm would have, in general

view this post on Zulip Folkert de Vries (Apr 27 2023 at 11:17):

so generally what we do is structural equality, and sometimes you can just compare pointers (references) and if they are the same then they must point to the same thing

view this post on Zulip Georges Boris (Apr 27 2023 at 13:19):

is the approach to always do pointers and then fallback to structural equality? (unless dealing with primitive types?

would equality checks inside a clojure automatically break the possibility of in-place mutation in that same clojure? since then a pointer value would not mean equality.

view this post on Zulip Ayaz Hafiz (Apr 27 2023 at 13:20):

Yes, pretty much. If the pointer equality check fails structural equality is still done. It doesn’t work for equating function types of course


Last updated: Jul 06 2025 at 12:14 UTC