Commit 6c73a4df authored by Marco Antoniotti's avatar Marco Antoniotti 💬
Browse files

Minor fixes to README layout.

parent 47859467
......@@ -35,7 +35,7 @@ comprised of three generic functions:
The WITH macro is practically expanded as follows.
(with (VAR CONTEXT-ITEM ...) &body CODE)
(with [VAR =] CONTEXT-ITEM do CODE)
becomes
......@@ -52,7 +52,7 @@ becomes
With this setup, `WITH-OPEN-FILE` can be immediately rewritten as
(with (f (open "some.txt"))
(with f = (open "some.txt") do
(loop for line = (read-line f)
while line
do (do-stuff-to line)))
......@@ -63,7 +63,7 @@ Something like the following.
(defmethod enter ((s file-stream) &key)
(if (open-stream-p s)
s
(error "Stream ~S is not open." context-item)))
(error "Stream ~S is not open." context-item)))
(defmethod handle ((s file-stream) (e error) &key)
(call-next-method))
......@@ -96,20 +96,20 @@ statement as follows:
```
(with (stack (exit-stack))
(let\* ((files (mapcar (lambda (fname)
(let* ((files (mapcar (lambda (fname)
(enter-context stack (open fname)))
\*filenames\*)))
*filenames*)))
;; Hold on to the new exit stack (not the method pointe as in the
;; Python example), but don't call its UNWIND method
(setf \*close-files\* (pop-all stack))
(setf *close-files* (pop-all stack))
;; If opening any file fails, all previously opened files will be
;; closed automatically. If all files are opened successfully,
;; they will remain open even after the with statement ends.
;;
;; (unwind \*close-files\*)
;; (unwind *close-files*)
;;
;; can then be invoked explicitly to close them all.
......
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