Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 
complete.

-- 
"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 
Brian


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners