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
[Caml-list] tail call optimization
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-11-19 (16:24)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] tail call optimization
On Tue, 18 Nov 2003, Dustin Sallings wrote:

> On Nov 18, 2003, at 22:50, Brian Hurt wrote:
> > This function is not tail recursive.  Basically, if the recursive call
> > either a) is wrapped in a try block, or b) has it's return value 
> > modified
> 	I guess I don't understand the point of clause a.  The try block 
> doesn't seem like it should prevent the optimization.

What would happen if f just happened to throw an End_of_file exception?  
Not to mention the fact that it's tricky for the compiler to determine 
that the call to fold_lines can't throw an End_of_file.  So the compiler 
just assumes that both might, and thus has to keep the try/catch block, 
and the context (stack frame) of the function, alive until both are 

"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 

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