Date: Tue, 02 Mar 1999 14:06:32 +0100
From: Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr>
To: "Sumlssillo, David" <sussillo@ftintl.com>, caml-list@inria.fr
Subject: Re: callcc/throw...
If you really need callcc/throw (that is try ... with ... is not enough), this
means you are implementing an algorithm which is bactracking. callcc needs to
save the current stack. this is not very hard as you can copy only the first
page of the stack and delay the other copy when needed. However this keeps a
lot of pointer and will often leads to a lot of memory leaks.
Indeed the stack may contains value that are not related to your backtracking
or that could be recomputed easely.
It is often better (not always) to directly implement your algorithm with the
bactracking explicit (that is keeping a stack of state from which you can
backtrack).
The code is often more difficult to write (you are doing a CPS translation by
hand) but you can gain a lot by
- keeping only what is needed in the state
- not keeping the state from which you know you do not need to backtrack
(most of the time you have a lot of these which are preserved in the stack if
you use callcc)
Christophe Raffalli
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:20 MET