caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Julian Brown <brown@cs.bris.ac.uk>
To: caml-list@inria.fr
Subject: [Caml-list] Conditional compilation in interface files
Date: Thu, 22 Jul 2004 21:43:58 +0000 (UTC)	[thread overview]
Message-ID: <slrncg0d63.nvt.brown@panic.cs.bris.ac.uk> (raw)

Hi,

I have a program which is written in two parts, one of which works OK,
and one of which isn't finished yet. These two parts are intermingled
somewhat, but I'd like to be able to conditionally compile a version of
the working part (on its own) with the hooks into the other part
removed, so I can release it.

My ideas so far are:

 * Use -pp with the C preprocessor (but it gets confused by some Ocaml
 syntax).

 * Use camlp4 with pa_macro.cmo, but I can't get it working!

In particular, I can't get pa_macro.cmo to conditionally compile bits
of interface files. I have this:

IFDEF SIMONLY THEN
class services :
  object
    method getdescriptor : int -> Unix.file_descr
    method getdishelp : disassembler_helper
    method insertdescriptor : int -> Unix.file_descr -> unit
    method killdescriptor : int -> unit
    method newdescriptor : Unix.file_descr -> int
    method querydescriptor : int -> bool
    method getoptlimit : int option
    method setoptlimit : int option -> unit
    method testoptok : bool
    method bumpopt : unit
  end
ELSE
class services :
  object
    method getallocator : Alloc.zone
    method getindexer : Index.indexer
    method getprofiler : Profiler.profiler
    method getdescriptor : int -> Unix.file_descr
    method getdishelp : disassembler_helper
    method insertdescriptor : int -> Unix.file_descr -> unit
    method killdescriptor : int -> unit
    method newdescriptor : Unix.file_descr -> int
    method querydescriptor : int -> bool
    method getoptlimit : int option
    method setoptlimit : int option -> unit
    method testoptok : bool
    method bumpopt : unit
  end
ENDIF;;

This gives me:

Parse error: [interf] expected after [sig_item_semi] (in [interf])

The docs don't appear to suggest to me that it should work even. Is
there a better way of doing this? (And do I have to use the revised
syntax for this extension?)

I'd like to keep my development code monolithic for now, so I don't
really want to separate the unfinished bit into a shared library or
anything like that.

Any hints appreciated! I'm using Ocaml 3.07, 3.08.0 behaves the same for
this.

Cheers,

Julian

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


                 reply	other threads:[~2004-07-22 21:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=slrncg0d63.nvt.brown@panic.cs.bris.ac.uk \
    --to=brown@cs.bris.ac.uk \
    --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).