[m-dev.] Trailing
Bart Demoen
bmd at cs.kuleuven.ac.be
Wed Aug 13 17:50:56 AEST 1997
Peter Schachte writes:
> But I have another idea. For this source code
>
> p(A, Z) :-
> ( mangle_array(A, A1),
> test(A1) ->
> q(A1, Z)
> ; q(A, Z)
> ).
>
> we generate code that looks like
>
> prev_trail = trail_pointer
> call mangle_array/2
> if (call test/1) {
> notify trailed functions that they are being trimmed
> trail_pointer = prev_trail
> call q/2
> } else {
> untrail back to prev_trail
> trail_pointer = prev_trail
> call q/2
> }
This has a problem if mangle_array/2 (or test/1) calls p/2. Can't you
store the prev_trail in the "environment" of p/2 ? (or was that your
intention ?) Another thing: you might want to store also the current
heap top if you want to recover heap space used during the If in case
it fails.
Putting TR and H in local variables was how if-then-else was
implemented in BIM (for certain tests only). Also HB := H temporarily
to do correct trailing ... (sorry for talking WAM :-)
Bart
More information about the developers
mailing list