I am trying to understand what the physical equality operators ( Pervasives.(==) and Pervasives.(!=) ) Mean in OCaml.
The instruction manual says that the expression "" is a "constant" and not an "expression":
constant :: == ... string-literal
but I cannot find a phrase indicating that the constants are once / pre-evaluated or combined, and REPL indicates that mutable string values (fortunately) are not combined.
(* a *) "" == "";; (* false *) (* b *) "foo" == "foo";; (* false *) (* c *) "" == String.copy "";; (* false *) (* d *) () == ();; (* true *) (* e *) (42, -42) == (42, -42);; (* false *) (* f *) ("", 1) == ("", 1);; (* false *) (* g *) None == None;; (* true *) (* h *) (Some None) == (Some None);; (* false *)
Section " 19.3 Representation of OCaml Data Types " assumes that language specification requires bools, ints, chars, a unit value, simple options, and empty lists are disinterested.
Should the implementation behave as described above as an executable implementation of OCaml?
Can the running OCaml implementation rewrite the pointer to b to point to a when a = b (* structurally *) is true, and both are values of immutable type (or actually immutable values, such as strings / arrays of zero length), as sometimes made to reduce the number of achievable low values in the GC generation?
source share