News for hackers. Stuff that matters.
Re:FP vs. OO, from the trenches by silentOpen on Monday July 22, 2013 @04:36PM (#6086305)
http://caml.inria.fr/pub/docs/manual-ocaml/manual005.html#to...

If you have only pure objects, you can still perform open recursion and leverage structural polymorphism (including row variables). Additionally, your objects are just values and, because they aren't mutable, can be held for backtracking.

For instance:

```ocaml class virtual biggable x = object val x = x method x : int = x method virtual embiggen : biggable end

let o = object (self) inherit biggable 0 method embiggen = {< x = x + 1 >} end

let q f o = object (self) val x = o#x method x = x method embiggen = f {< x = x * 2 >} end

let a = q (q (fun x -> object inherit biggable x#x method embiggen = {< >} end)) o#embiggen

;; # a#x;; - : int = 1 # a#embiggen#x;; - : int = 2 # a#embiggen#embiggen#x;; - : int = 4 # a#embiggen#embiggen#embiggen#x;; - : int = 4 ```

There are no comments on this comment yet.