Dear Bart,
first of all, thank you for your answer. You caught my doubt very well. It would be very helpful if you could send me the report you told about.
thanks, kind regards Silvia Umiliacchi
----Messaggio originale---- Da: Bart.Demoen(a)cs.kuleuven.be Data: 28/06/2011 20.16 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
Hi Silvia,
A Prolog system that does not implement LCO would not survive long. You are right about catch/3 preventing LCO to some extent. You could have a look at how catch/3 is implemented: depending on that, LCO is dynamically (and locally) disabled, in a "natural" way. It is not something the compiler (from Prolog to WAM for instance) needs to know about. I can send you privately an old report named "A 20' implementation of catch and throw in WAM" - SWI Prolog implements it differently - I do not know how Ciao does it, but at some point in SICStus, it was basically as my report describes, and Ciao derives from SICStus.
In a nutshell: LCO is (dynamically) detected not to apply if there is a choicepoint blocking the reuse of an environment. The implementation of catch/3 can push the necessary choicepoint (for unwinding) in such a way that no special action is needed.
Cheers
Bart Demoen
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm