Before implementing import name resolution, then after fic macro imports
This commit is contained in:
@@ -1,35 +1,6 @@
|
||||
(define (type-wrap obj type)
|
||||
(set-type obj type)
|
||||
obj)
|
||||
(import "oo.slime")
|
||||
|
||||
(define-syntax (defclass name members :rest body)
|
||||
"Macro for creating classes."
|
||||
(define (underscore sym)
|
||||
(string->symbol (concat-strings "_" (symbol->string sym))))
|
||||
|
||||
(define underscored-members (map underscore members))
|
||||
|
||||
;; the wrapping let environment
|
||||
(define let-body `(let ,(zip members underscored-members)))
|
||||
|
||||
;; the body
|
||||
(map (lambda (fun) (append let-body fun)) body)
|
||||
|
||||
;; the dispatch function
|
||||
(append let-body `(type-wrap
|
||||
(special-lambda
|
||||
(message :rest args)
|
||||
"This is the docs for the handle"
|
||||
(eval (extend (list message) args))) ,(symbol->keyword name)))
|
||||
|
||||
;; stuff it all in the constructor function
|
||||
`(define
|
||||
,(pair (string->symbol (concat-strings "make-" (symbol->string name))) underscored-members)
|
||||
,(concat-strings "This is the handle to an object of the class " (symbol->string name))
|
||||
,let-body))
|
||||
|
||||
|
||||
(defclass vector3 (x y z)
|
||||
(define-class vector3 (x y z)
|
||||
(define (get-x) x)
|
||||
(define (get-y) y)
|
||||
(define (get-z) z)
|
||||
|
||||
Reference in New Issue
Block a user