caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Can this be inlined?
@ 2011-01-10 21:22 Jacques Carette
  2011-01-10 21:31 ` Michael Ekstrand
  2011-01-11  8:52 ` Damien Doligez
  0 siblings, 2 replies; 3+ messages in thread
From: Jacques Carette @ 2011-01-10 21:22 UTC (permalink / raw)
  To: caml-list

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-11  8:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-10 21:22 [Caml-list] Can this be inlined? Jacques Carette
2011-01-10 21:31 ` Michael Ekstrand
2011-01-11  8:52 ` Damien Doligez

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).