From: Richard Jones <rich@annexia.org>
To: caml-list@inria.fr
Subject: [Caml-list] I need a C preprocessor
Date: Thu, 28 Aug 2003 17:09:19 +0100 [thread overview]
Message-ID: <20030828160919.GA8257@redhat.com> (raw)
Here is some code I've just written. CjsConfig.debug_menu is a
compile-time constant.
let debug_menu =
if CjsConfig.debug_menu then
Some (factory#add_submenu "Debug")
else
None in
(* ... *)
let single_step_ev_item, single_step_res_item, step_to_item,
dump_hiertext_item =
match debug_menu with
None -> None, None, None, None
| Some debug_menu ->
let factory = new GMenu.factory debug_menu ~accel_group in
let single_step_ev_item =
factory#add_item "Single Step (1 Event)"
~key:GdkKeysyms._T in
let single_step_res_item =
factory#add_item "Single Step (1 Result Period)"
~key:GdkKeysyms._Z in
let step_to_item = factory#add_item "Step To ..." in
factory#add_separator ();
let dump_hiertext_item =
factory#add_item "Dump HierText To Console"
~key:GdkKeysyms._H in
(Some single_step_ev_item, Some single_step_res_item,
Some step_to_item, Some dump_hiertext_item)
in
Now in C I'd use the preprocessor:
#ifdef DEBUG_MENU
factory#add_submenu "Debug"
#endif
#ifdef DEBUG_MENU
let factory = new GMenu.factory debug_menu ~accel_group in
let single_step_ev_item = factory#add_item "Single Step (1 Event)"
(* etc. *)
#endif
which results in briefer, faster and simpler to understand code.
My question is what is the proper style for this sort of thing in
OCaml?
Rich.
--
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
NET::FTPSERVER is a full-featured, secure, configurable, database-backed
FTP server written in Perl: http://www.annexia.org/freeware/netftpserver/
-------------------
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
next reply other threads:[~2003-08-28 16:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-28 16:09 Richard Jones [this message]
2003-08-28 17:33 ` Issac Trotts
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=20030828160919.GA8257@redhat.com \
--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