diff options
author | Aaron Zeng <zeng.aaron.l@gmail.com> | 2015-04-21 15:08:39 -0400 |
---|---|---|
committer | Aaron Zeng <zeng.aaron.l@gmail.com> | 2015-04-21 15:08:39 -0400 |
commit | 6b2d8d5fe2556316c6cff7f876153716ce296183 (patch) | |
tree | f555bd46d1dc1ccb72ffb32859c3a3a32788d2e9 /common-lisp.html.markdown | |
parent | a5d38aedd5a6fe4632591c302270fde1c6613827 (diff) |
fix the while macro for Common Lisp
Earlier version was incorrect, as it only executed `body` once and then terminated, like an if statement instead.
Diffstat (limited to 'common-lisp.html.markdown')
-rw-r--r-- | common-lisp.html.markdown | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/common-lisp.html.markdown b/common-lisp.html.markdown index c4ecb5e8..f9f64d68 100644 --- a/common-lisp.html.markdown +++ b/common-lisp.html.markdown @@ -573,13 +573,15 @@ nil ; for false - and the empty list "While `condition` is true, `body` is executed. `condition` is tested prior to each execution of `body`" - (let ((block-name (gensym))) + (let ((block-name (gensym)) (done (gensym))) `(tagbody + ,block-name (unless ,condition - (go ,block-name)) + (go ,done)) (progn ,@body) - ,block-name))) + (go ,block-name) + ,done))) ;; Let's look at the high-level version of this: |