wkentaro
11/7/2015 - 1:52 PM

continue on lisp

continue on lisp

;; vim: set ft=lisp:

;; --------------------------------------------------
;; without macro
;; --------------------------------------------------
(setq cnt -1)
(while
  (< cnt 10)
  (tagbody
    while-loop-top
    (incf cnt)
    (when (eq (mod cnt 3) 0) (go while-loop-top))
    (print (format nil "now at ~a" cnt))
    )
  )

;; --------------------------------------------------
;; with macro
;; --------------------------------------------------
(defmacro while2 (cnd &rest body)
  `(while
     ,cnd
     (tagbody while-loop-top ,@body)
     )
  )
(defmacro continue2 () `(go while-loop-top))

(setq cnt -1)
(while2
  (< cnt 10)
  (incf cnt)
  (when (eq (mod cnt 3) 0) (continue2))
  (print (format nil "now at ~a" cnt))
  )
(exit)