English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2003-01-10 (02:59)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] record declaration, SML

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 =
      class a = object val f = 1 method f = f end
  C (new M.a)

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

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