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
Emulating width subtyping with 1st-class modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-08-05 (16:17)
From: Alain Frisch <alain@f...>
Subject: Re: [Caml-list] Emulating width subtyping with 1st-class modules
On 08/05/2010 06:10 PM, Philippe Veber wrote:
> I have a related question: the only reason why i'm not fully happy with
> objects used as anonymous records is that i sometimes use them as mere
> data containers and need to save (marshal) them at some point. Which is
> not permitted as soon as you want to exchange marshalled values between
> two different programs. Hopefully one can rely on json-static to cope
> with that limitation in a quite elegant way. Are first-class modules
> distinct in that respect ? That is, can they be marshalled if they do
> not contain closures ?

Yes, they can be marshaled. As usual with marshaling, you don't get any 
type safety.

That said, first-class modules cannot really be used to simulate 
anonymous records since they rely on nominal typing: even if S and S' 
refer to identical signatures, the types (module S) and (module S') are 
not equal.