News for hackers. Stuff that matters.
Re:OCaml: Objects by rwmj on Monday March 16, 2015 @01:14PM (#9212761)
I believe it's because #info (ie. method access) is kind of dynamic. The string "info" is hashed and then the hash is looked up at runtime against the class vtable. (For precise details, see 19.3.5 here: http://caml.inria.fr/pub/docs/manual-ocaml/intfc.html) I'm not clear under what circumstances this can be optimized to a direct call, and there is also some kind of cache, so repeated method calls to the same method are fast. This is the reason people who value performance over everything else steer clear of using objects in OCaml.

Record fields are simply offsets in a struct, so the type must be fully known when compiling the code. It would not be possible to compile a function that could work on two different types of struct that both happened to have a .info field.

Re:OCaml: Objects by kxyvr on Monday March 16, 2015 @02:22PM (#9213250)
Actually, that makes a lot of sense. Thanks for the insight.