Dear Jose,
thank you for your answer.
I'll have a look at the paper you suggested me.
Kind regards,
Silvia Umiliacchi
>----Messaggio originale----
>Da: jfran(a)clip.dia.fi.upm.es
>Data: 28/06/2011 18.24
>A: "silviaumiliacchi(a)libero.it"<silviaumiliacchi(a)libero.it>
>Cc: <ciao-users(a)clip.dia.fi.upm.es>
>Ogg: Re: [Ciao-users] Question about tail call optimization
>Dear Silvia,
>
>Last call optimization (LCO) removes frame environments when possible,
>thus transforming some recursions into loops. That optimization is
>done at compile time when possible. There are many papers in the
>literature where you can find a more detailed description
>(H. Ait-Kaci. Warren's Abstract Machine, A Tutorial
>Reconstruction). Basically, given a clause:
>
> p :- g1, g2, ..., gn1, gn.
>
>the compiler translates it into code (e.g., bytecode) that, between
>'gn1' and 'gn', makes sure that all the arguments required for 'gn'
>live in temporal registers, removes the environment frame, and jumps
>to 'gn'.
>
>In order to reason about catch/3 and throw/1 you need some detailed
>description of their semantic. Suppose a clause like:
>
> foo :- ..., catch(bar, ..., ...).
>
>If your question is whether LCO is able to remove the environment
>created for 'foo' before calling 'bar', the answer is no. At least,
>you need to 'uninstall' the exception handler when returning from
>'bar'. To do that, you need to keep some information in the
>enviroment. I do not think that it could be optimized (at least I am
>not aware of any Prolog system which does).
>
>Cheers
>
>--
>Jose
>