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: Frederic van der Plancke <fvdp@d...>
Subject: Re: [Caml-list] tail call optimization
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
> > in any way, the function isn't tail recursive.  Your function violates
> > clause a, the following function violates clause b:
> >
> > let append a b =
> >       match a with
> >               | [] -> b
> >               | h :: t -> h :: (append t b)
> > ;;
> 
>         I guess I don't understand the point of clause a.  The try block
> doesn't seem like it should prevent the optimization.

Any work your function has to do before the called function returns
prevents tail-call optimisation. Unsetting a "try" exception handler is work
that has to be done at the level of the corresponding "with".

Frédéric

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