;;
;;      Name: macros
;;
;;      Functions:  basic macros for iterative loops and
;;                  if statements
;;
;;      Author: Alan W Black September 1984
;;              Dept of A.I.
;;              University of Edinburgh
;;
;;      Copyright Graeme Ritchie, Alan Black,
;;                Steve Pulman and Graham Russell  1987
;;
;;         ---------------------------------------------
;;         |    Not to be used for military purposes   |
;;         ---------------------------------------------
;;
;;

(defmacro D-repeat (statements until condition)
;;
;;   This macro offers a repeat until construct of the form
;;   (repeat ( staements ) until condition)
;;
  (cond
     ((not (eq until 'until)) (error "Syntax Error in D-repeat - no until"))
     (t
	`(prog ()
	 loop
	    ,@statements
	    (cond
	      ((not ,condition) (go loop)))
	 )
      )
   )
)

(defmacro D-while (test &rest statements)
;;
;;  This defines a macro for the while construct
;;     (while test  statement1 statement2 ...)
;;
   `(prog ()
    loop
       (cond
	 ((not ,test) (return)))
        ,@statements
	(go loop))
)

(defmacro D-if (test then &rest statements)
;;
;;  This offers the if.. then .. construct (no else)
;;  syntax is
;;     (if  condition then statement statement ...)
;;
   `(cond
      (,test ,@statements))
)
