[cvs-nhc98] In Hat combinator library reintroduce stack for entered re
User olaf
olaf@sparud.net
Mon, 6 May 2002 13:31:30 +0200 (CEST)
olaf: Mon May 6 13:31:29 CEST 2002
Update of /usr/src/master/nhc/src/hat/lib
In directory hinken:/tmp/cvs-serv6239/src/hat/lib
Modified Files:
Hat.hs hat.c hat.h
Log Message:
In Hat combinator library reintroduce stack for entered redexes and use a buffer only for deferred updating of reduced redexes.
The main advantage is that we obtain a good entry point for hat-trail into the trace if the computation was interrupted or aborted with an error that was only caught as an exception in Haskell or on the C-side. The entry point is the last redex that was entered but not yet reduced.
The reference of a reduced redex is always compared with the reference on top of the stack to recognise the situation where a Haskell exception renders part of the stack garbage. Then the stack is popped until an entry with the same reference is found. The popped entries (except for the last) are written as Entered into the trace. However, it seems there are never any such entries anyway, because IO-actions always reduce successfully to Abstract "IO". Need good test case.
Interruptions often happen at an entered Forward. These do not however have a parent in the trace. Hence the combinator library at least keeps a parent for every Forward on the stack, so that the entry point can be that parent. (Actually unevaluated and entered Forwards should have a parent; but that needs change of trace file format).
Stack plus buffer also seems to be slightly more efficient than the previous buffering method.