Commit 7782b30b authored by Marco Antoniotti's avatar Marco Antoniotti 💬
Browse files

Fixed bug in POP-ALL. Transfer and zeroing of the stacks was not done correctly.

parent 47bd86f5
......@@ -11,6 +11,7 @@
(defclass exit-stack-context (context)
((callback-stack :initform ()
:type list ; A stack.
:reader callback-stack
:writer set-callback-stack ; Unexported. See POP-ALL below.
))
......@@ -100,7 +101,7 @@ examples.
(:method ((es exit-stack-context))
(let ((nes (exit-stack)))
(set-callback-stack (callback-stack es) nes)
(set-callback-stack (callback-stack es) ())
(set-callback-stack () es)
;; Note that this zeroing the callback stack is implied by the
;; "transfer" in the Python's documentation.
......@@ -162,13 +163,13 @@ examples.
;;;; Example from Python doc.
;;;; This should be pretty much equivalent.
#|
(with (stack (exit-stack))
#| New syntax
(with stack = (exit-stack) do
(let* ((files (mapcar (lambda (fname)
(enter-context stack (open fname)))
(enter-context stack (open fname))) ; Need to wrap OPEN.
*filenames*)))
;; Hold on to the new exit stack (not the method pointe as in the
;; Hold on to the new exit stack (not the method pointer as in the
;; Python example), but don't call its UNWIND method
(setf *close-files* (pop-all stack))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment