From: Jacques Carette <carette@mcmaster.ca>
To: caml-list@inria.fr
Subject: [Caml-list] Can this be inlined?
Date: Mon, 10 Jan 2011 16:22:27 -0500 [thread overview]
Message-ID: <4D2B7893.5030802@mcmaster.ca> (raw)
I am experimenting with some fairly generic traversal code (over a
complex AST), but am a little scared that the result will be horribly
inefficient. I have been trying (with -dlambda and -dcmm, but not
reading the .s output from using -S) to experiment with this myself,
unsuccessfully. Here is a very simplified setup
type ('a,'b) t = A | B of 'a * ('a,'b) t | C of 'b * ('a, 'b) t
type ('a, 'b) ff = { a: ('a -> 'a) option; b : ('b -> 'b) option }
let oapply optf x = match optf with Some f -> f x | None -> x
let id x = x
let rec trav f = function
| A -> A
| B (x,e) -> B (oapply f.a x, trav f e)
| C (x,e) -> C (oapply f.b x, trav f e)
let t1 = {a=Some id; b=None}
let tt x = trav t1 x
I would like for 'tt' to contain a version of trav with no traces of
either oapply or t1 left. How can I achieve that? Is it possible? I
don't mind changing idioms (modules instead of record, etc), as long as
I can get my inlining to go through. [I also tried making oapply and
trav "local" to tt's definition, but that did not seem to make much of a
difference].
In any case, the real goal here is to see if I can safely adopt a coding
style like this, or do I need to manually do all the inlining myself?
Jacques
next reply other threads:[~2011-01-10 21:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-10 21:22 Jacques Carette [this message]
2011-01-10 21:31 ` Michael Ekstrand
2011-01-11 8:52 ` Damien Doligez
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=4D2B7893.5030802@mcmaster.ca \
--to=carette@mcmaster.ca \
--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