Fixed a bug where cs was accessed out of bouds, gensyms, 'and and 'or are now macros

This commit is contained in:
Felix Brendel
2020-03-17 12:06:55 +01:00
parent aac3985a61
commit e22ffb7354
5 changed files with 161 additions and 196 deletions
+33
View File
@@ -25,6 +25,39 @@
(define-syntax (mac a) (list + 1 1))
(define-syntax (add . args) (pair '+ args))
(define-syntax (and . args)
;; (and cond1 cond2 (cond3 args))
;; ->
;; (if cond1
;; (if cond2
;; (let ((g (cond3 args)))
;; (if g
;; g
;; ()))
;; ())
;; ())
(if args
`(,if ,(first args)
,(apply and (rest args))
())
t))
(define-syntax (or . args)
;; (or cond1 cond2 (cond3 args))
;; ->
;; (if cond1
;; t
;; (if cond2
;; t
;; (if (cond3 args)
;; t
;; ())))
(if args
`(,if ,(first args)
t
,(apply or (rest args)))
()))
(define-syntax (when condition . body)
"Special form for when multiple actions should be done if a
condition is true.