caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rich@annexia.org>
To: caml-list@inria.fr
Subject: [Caml-list] #use is not textual inclusion
Date: Sat, 29 Feb 2020 08:53:19 +0000	[thread overview]
Message-ID: <20200229085319.GD11122@rich.annexia.org> (raw)

I was trying to break up a large ocaml interpreted script:

  https://github.com/libguestfs/libnbd/blob/master/generator/generator

The script contains sections like:

  module Foo : sig
  (* type signature *)
  end = struct
  (* very long implementation *)
  end

and it would be convenient for me to move the implementations into
separate files.  However this doesn't work:

  module Foo : sig
  (* type signature *)
  end = struct
  #use "implementation.ml"  (* with or without ;; here *)
  end

So I guess #use only works for top level statements, which surprised
me and contradicts the documentation here too:

  https://caml.inria.fr/pub/docs/manual-ocaml/toplevel.html#s%3Atoplevel-directives

I could move the whole module definition to the file, but then I would
lose the advantage of hiding the implementation while keeping the
signature visible in the main file.

Given the constraint that we can't use ocamlc or cppo (because of
minimal build dependencies), are there any alternatives?  My first
thought was C's cpp, but it seems impossible to get that working with
#!/usr/bin/env and preserve the "scriptiness" of being able to just do
./generator/generator to run it.

Rich.

             reply	other threads:[~2020-02-29  8:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-29  8:53 Richard W.M. Jones [this message]
2020-02-29  9:09 ` Gabriel Scherer
2020-02-29 10:32   ` Richard W.M. Jones

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=20200229085319.GD11122@rich.annexia.org \
    --to=rich@annexia.org \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).