reasonml / reason

Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems
http://reasonml.github.io
MIT License
10.13k stars 428 forks source link

Physical equality should be named structural equality? #1851

Closed nikgraf closed 6 years ago

nikgraf commented 6 years ago

In my research about Reason was reading up more on OCaml and got confused about the wording.

In OCaml they seem to differentiate between structural and physical equality. The Reason codebase as well as in the Reason docs mention physical and reference equality as two different things while from my understanding they are the same.

Currently the mapping seems like this to me

Physical Equality in OCaml (==) maps to Referential Equality (===) in Reason Structural Equality in OCaml (=) maps to Physical Equality (==) in Reason

Which results in

Physical equality in OCaml IS NOT phyiscal equality in Reason

Possible Solution

Physical Equality in OCaml (==) maps to Referential Equality (===) in Reason Structural Equality in OCaml (=) maps to Structural~Physical~ Equality (==) in Reason

Occurrences in Reason Codebase and Docs

Docs mention: https://reasonml.github.io/docs/en/overview.html ReasonML code: https://github.com/facebook/reason/blob/7b13876edc65b2b1043e86c5c5c13fefb06e65a0/formatTest/typeCheckedTests/input/mlSyntax.ml#L50-L56

Shouldn't this be structural and referential equality?

OCaml Resources

OCaml Cheetsheet - http://www.ocamlpro.com/files/ocaml-lang.pdf

http://www2.lib.uchicago.edu/keith/ocaml-class/operators.html

OCaml distinguishes between structural equality and physical equality (essentially equality of the address of an object). = is structural equality and == is physical equality.

nikgraf commented 6 years ago

I created PRs in case there is interest for this change:

https://github.com/facebook/reason/pull/1852 https://github.com/reasonml/reasonml.github.io/pull/328

jordwalke commented 6 years ago

"Physical Equality in OCaml (==) maps to Referential Equality (===) in Reason"

I may be misinterpreting this, but the truth is that Physical Equality in OCaml maps to Physical Equality in Reason. The same for Referential. The only thing that is different is the symbol that we use to reference those concepts. That is likely what you meant, but I thought I would clarify for anyone listening.

jordwalke commented 6 years ago

Thank you.