On Tue, 8 Nov 2005, Daniel Bünzli wrote: > > Le 8 nov. 05 à 03:15, Brian Hurt a écrit : > >> So patterns like singletons are hard to implement with Ocaml objects. > > Don't you have immediate objects [1] to do singletons ? No- because immediate objects still allocate a new object every time they are evaluated. I suppose you could do: let factory = let myobject = new myclass in fun () -> myobject ;; and do a factory method, but there is no way (that I know of) to prevent someone else from doing: let myotherobject = new myclass and allocating a different object of the same class. No, the proper way to do singletons in Ocaml is with modules, not objects. Brian