Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
RE: [Caml-list] @, List.append, and tail recursion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-01-30 (01:44)
From: brogoff@s...
Subject: RE: [Caml-list] @, List.append, and tail recursion
Thanks for the reference. I get nailed by this a couple of times a 
year, and I usually just blame myself for being sloppy and recode 
all of my maps, appends, and filters to remove it. I think it would 
be great if those three functions (at least) could be tail recursive, 
either by having the compiler do it or by providing these "hole 
abstractions" in the language. 

I wonder, like the other Brian, if there are existing ML compilers which 
implement this optimization, and if there is any chance we'll see this in 

On Fri, 24 Jan 2003, Andrew Kennedy wrote:
> Brian,
> The optimization you describe is sometimes known as
> "tail modulo cons", and is an example of "destination-passing
> style". In other words, the place to put the result (in
> this case, the address of the tail of a just-constructed 
> cons cell) is passed on in a tail-recursive call.
> See "A Functional Representation of Data Structures with a Hole"
> by Minamide in POPL'98.
> Although Minimide formalizes the problem in the context of
> a typed intermediate language, it's probably quite easy to 
> spot special cases quite far down the compiler pipeline.
> - Andrew.
> > -----Original Message-----

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: