5 ms·
I wouldn't label Rust as being less safe than OCaml. You have to explicitly opt-in to any unsafe operations. More often than not, the unsafe blocks are needed b
by gfs 7y ago
I wouldn't label Rust as being less safe than OCaml. You have to explicitly opt-in to any unsafe operations. More often than not, the unsafe blocks are needed because the compiler can not check all of the invariant cases.
- saagarjha 7y agoDoes OCaml even have a way of shedding memory safety?
- ncmncm 7y agoOCaml is an "obligate-GC" language. Most languages that offer optional GC, including Rust (with its RC and ARC boxing) and C++ (with std::shared_ptr), implement it mainly via reference-counting.
- tomp 7y agoYes, the `Unsafe` module (well, at least used to have it... fairly undocumented... maybe it's been removed?).
- tomp 7y agoOops, I misremembered the name. @pcwalton is right, it's called `Obj`.
- pcwalton 7y agoSure. Obj.magic is a bit cast.
- ori_b 7y ago> You have to explicitly opt-in to any unsafe operations Many of the unsafe operations don't exist in OCaml. Often because the GC makes them unnecessary.
- pcwalton 7y agoYou can implement all of the unsafe operations in OCaml using the unsafe Obj.magic cast: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Obj.html http://caml.inria.fr/pub/docs/manual-ocaml/libref/Obj.html