Version française
Home     About     Download     Resources     Contact us    
Browse thread
Invoking the standard library ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Eric Cooper <ecc@c...>
Subject: Re: [Caml-list] Invoking the standard library ?
On Tue, Apr 29, 2008 at 04:26:45PM +0200, David Teller wrote:
> modules String, Stream, etc. For this, I need to include the original
> module, as provided in the standard library, and add stuff. Now, the
> trick is that I'd like to keep the same name as the original module.

My first thought was that the usual shadowing of bindings could
be used, and indeed the following works fine in the toplevel:

module String =
  struct
    include String
    let my_extension = ...
  end

But when I tried to compile it separately (just
    include String
    let my_extension = ...
in a file "string.ml"), I got an error "Unbound module String".

I don't understand why the behavior is different in these two cases;
apparently the batch compiler binds String as soon as it starts compiling
"string.ml", whereas the top-level does so only after compiling the
struct body.  Is this a bug?

-- 
Eric Cooper             e c c @ c m u . e d u