implement vectors

This commit is contained in:
Felix Brendel
2019-08-08 14:21:30 +02:00
parent 5fa2c1bbf9
commit 4f2793b7ef
13 changed files with 279 additions and 1125 deletions
+29 -12
View File
@@ -1,3 +1,5 @@
(define-syntax (pe expr)
`(printf ',expr "evaluates to" ,expr))
@@ -141,18 +143,33 @@ ithe sequence as arguemens."
(assert-types= @lambda-list)
@body)))
(define-syntax (define-package name :rest body)
`(define ,(string->symbol (concat-strings (symbol->string name) "->"))
((lambda ()
@body
(set-type
(special-lambda (:rest args)
(let ((op (first args))
(args (rest args)))
(if (callable? (eval op))
(apply op args)
(eval op))))
:package)))))
(define-syntax (define-module module-name :keys exports :rest body)
(let ((module-prefix (concat-strings (symbol->string module-name) "::")))
(eval `(begin @body))
(pair 'begin
(map (lambda (orig-export-name)
(let ((export-name (string->symbol
(concat-strings module-prefix
(symbol->string orig-export-name)))))
`(define ,export-name
,(try (eval orig-export-name)
(error "The module does not contain" orig-export-name)))))
exports))))
;; (define-syntax (define-package name :rest body)
;; `(define ,(string->symbol (concat-strings (symbol->string name) "->"))
;; ((lambda ()
;; @body
;; (set-type
;; (special-lambda (:rest args)
;; (let ((op (first args))
;; (args (rest args)))
;; (if (callable? (eval op))
;; (apply op args)
;; (eval op))))
;; :package)))))
(define (null? x)
"Checks if the argument is =nil=."