On Thu, Jul 24, 2008 at 02:27:51PM -0500, Raj Bandyopadhyay wrote: > Hi OCaml folk > > I apologize if I've been asking too many questions on this list > recently, but I'm working on a heavy OCaml application and need help > sometimes. > > I am having a disagreement with a colleague about how the equality > operators in OCaml work and am trying to resolve it conclusively. > > 1) I understand that the '==' operator is basically a pointer comparison > i.e. a==b true iff a and b are the same entity. Is this true?
yes. only valid for object that are in blocks though (int, char are not). for object not in block, you end up with a simple = > 2) Where can I find the code implementing the '==' operator in the OCaml > code? byterun/compare.c : caml_equal which call compare_val with total=0 (which means to not compare inside blocks) > 3) In case I do want to check object identity and can use the == > operator, would it be faster to use '==', '=' or a match statement? i believe == is the fastest one. but that's just based on how the thing works compare to the others compare, not on empirical benchs. -- Vincent _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs