Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] record declaration, SML
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] record declaration, SML
Hi,

On Fri, Jan 10, 2003 at 12:14:17AM +0100, Alessandro Baretta wrote:
> 
> Interesting solution. However, Ocaml does not support 
> defining objects on the fly. The following
>  > let c = new object method f = 1 end in C c
> is not valid Ocaml.

You can do this:

  let module M =
    struct
      class a = object val f = 1 method f = f end
     end
  in
  C (new M.a)

It is a little bit tricky, but useful in an automatic translation
from SML to OCaml.

-- 
Daniel de RAUGLAUDRE
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners