new define-syntax syntax

This commit is contained in:
FelixBrendel
2019-04-21 22:17:36 +02:00
parent 903d9bdd8c
commit 4f82ff4115
+5 -5
View File
@@ -1,8 +1,8 @@
(define-syntax when (condition :rest body) (define-syntax (when condition :rest body)
"Doc String for 'when'" "Doc String for 'when'"
`(if ,condition ,(pair prog body) nil)) `(if ,condition ,(pair prog body) nil))
(define-syntax unless (condition :rest body) (define-syntax (unless condition :rest body)
`(if ,condition nil ,(pair prog body))) `(if ,condition nil ,(pair prog body)))
;; (define-syntax defun (name arguments :rest body) ;; (define-syntax defun (name arguments :rest body)
@@ -116,11 +116,11 @@ the (rest) of the last element of the sequence."
with (pair elem nil)." with (pair elem nil)."
(extend seq (pair elem nil))) (extend seq (pair elem nil)))
(define-syntax extend! (seq elem) (define-syntax (extend! seq elem)
"test" "test"
`(mutate ,seq (extend ,seq ,elem))) `(mutate ,seq (extend ,seq ,elem)))
(define-syntax append! (seq elem) (define-syntax (append! seq elem)
`(mutate ,seq (append ,seq ,elem))) `(mutate ,seq (append ,seq ,elem)))
(define (length seq) (define (length seq)
@@ -237,5 +237,5 @@ las argument."
(eval (pair printf-quoted (extend (list :@sep (eval sep) :@end (eval end)) args)))) (eval (pair printf-quoted (extend (list :@sep (eval sep) :@end (eval end)) args))))
(define-syntax pe (expr) (define-syntax (pe expr)
`(printf ',expr "evaluates to" ,(eval expr))) `(printf ',expr "evaluates to" ,(eval expr)))