Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Anastasia Gornostaeva <ermine@ermine.pp.ru>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] recmod
Date: 31 Dec 2004 12:10:21 +1100	[thread overview]
Message-ID: <1104455420.29293.66.camel@pelican.wigram> (raw)
In-Reply-To: <20041230223802.GA54521@ermine.home>

On Fri, 2004-12-31 at 09:38, Anastasia Gornostaeva wrote:

> Is it possible to compile such files?
> 
> mod1.ml: 
> let get a =
>    if Mod2.mem a then 1 else 2
> 
> mod2.ml:
> let mem a = List.mem a [1;2;3]
> let other () =
>    print_int (Mod1.get 5)
> 

No. There is a new experimental feature which provides
some support for intra-module recursion,
but at present the modules must reside
in the same file.

The two common workaround for functions are:

(a) pass Mod2.get to Mod1.get as an argument

(b) create a reference in mod1.ml initialised to 
  
   fun (x:int) -> raise Not_found; 1

   and in mod2.ml store Mod2.get into it, call it in mod1.ml
   by first dereferencing it.

Another technique is to use classes, which automate
the late binding more safely.

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net




      reply	other threads:[~2004-12-31  1:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-30 22:38 recmod Anastasia Gornostaeva
2004-12-31  1:10 ` skaller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1104455420.29293.66.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=ermine@ermine.pp.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox