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
Local opening of modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1998-10-28 (12:11)
From: John Prevost <j.prevost@c...>
Subject: Local opening of modules
This is a question that I found asked back in the logs, but which I
found no answer to:

Is there any good reason that Caml doesn't have a mechanism like SML's
to open a module locally?  For example:

let open Num in
let a = num_of_int 2739 in
let b = num_of_int 234 in
let bar = a +/ b;;

an even better example would be one in which the symbol "+/" was
actually "+", like in the SML bignum package.  A friend of mine used
this mechanism quite well in a project where bignum math was used in
only a few restricted places.  The rest of the file didn't need to be
polluted namespace-wise with the bignum package (and if there were, say,
another package that wanted +/ it wouldn't cause problems...  There are
only so many reasonable versions of + you can make without getting into
collision problems, after all.)

Maybe there's a technical constraint in the way Caml is organized that
keeps this from being done?