Not sure why all those operators are needed. What's the rationale? Why is not the regular OCaml object syntax enough?
obj##.m
obj##.m := e
obj##m
Documentation here: http://ocsigen.org/js_of_ocaml/3.6.0/manual/ppx
Not sure why all those operators are needed. What's the rationale? Why is not the regular OCaml object syntax enough?
obj##.m
obj##.m := e
obj##m
Documentation here: http://ocsigen.org/js_of_ocaml/3.6.0/manual/ppx
Copyright © 2021 Jogjafile Inc.
OCaml objects do not have properties. If you write
obj#m, you are calling methodmon objectobj. If you writeobj#m := e, you are again calling methodmon objectobjand it returns a value of type'e ref, which is then passed to operator(:=).Hence operator
##., which is just syntactic sugar for callingJs.Unsafe.get, respectivelyJs.Unsafe.set. (Similarly,obj##m x yis syntactic sugar forJs.Unsafe.meth_call obj "m" [|x; y|].)Rather than modifying the OCaml compiler in depth to actually map Javascript objects to OCaml ones and correctly recognize getters/setters, JSOO is a thin layer that depends on OCaml objects only for typing Javascript ones and ignores them entirely for execution.