From: Alain Frisch <alain.frisch@lexifi.com>
To: "Étienne André" <Etienne.Andre@univ-paris13.fr>, caml-list@inria.fr
Subject: Re: [Caml-list] Build number and date in OCaml?
Date: Thu, 11 Apr 2013 15:00:41 +0200 [thread overview]
Message-ID: <5166B3F9.9040105@lexifi.com> (raw)
In-Reply-To: <CAB+Vvvgfrez6qedMwyj4_2fjPy+x_DyGzSOBXKQ4paLNEtk3mg@mail.gmail.com>
On 04/09/2013 01:38 PM, Étienne André wrote:
> I quite stupidly used the Unix.gettimeofday() function before realizing
> that it is of course executed at runtime.
As others suggested, you can tell your build system to generate an ad
hoc file containing the compile-time information. Another approach is
to use a preprocessor to inject such compile-time information into the
source code "on the fly" during its compilation. This can be done with
a dedicated Camlp4 syntax extension or a -ppx preprocessor (available in
trunk only, with syntactic extension points being designed in the
extension_points branch of the OCaml SVN).
As an illustration of the -ppx approach, I've created a tiny
preprocessor which uses the OCaml toplevel to evaluate expressions and
inserts the result as constants in the compiled code.
The source code for this -ppx preprocessor can be found here:
http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/branches/extension_points/experimental/frisch/eval.ml?&view=markup
and here is an example of what you can write with it:
http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/branches/extension_points/experimental/frisch/test_eval.ml?&view=markup
(To play with it, you need to checkout the extension_points branch and
after compiling it: cd experimental/frisch && make eval)
-- Alain
next prev parent reply other threads:[~2013-04-11 13:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-09 11:38 Étienne André
2013-04-09 12:18 ` Jeremie Dimino
2013-04-10 8:49 ` Julien Signoles
2013-04-10 9:08 ` David Allsopp
2013-04-11 13:00 ` Alain Frisch [this message]
2013-04-12 14:38 ` Daniel Weil
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=5166B3F9.9040105@lexifi.com \
--to=alain.frisch@lexifi.com \
--cc=Etienne.Andre@univ-paris13.fr \
--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).