|
- (define-macro (define-class name-and-members . body)
- "Macro for creating simple classes."
- (let ((name (car name-and-members))
- (members (cdr name-and-members)))
- `(set-type!
- (define
- ;; The function definition
- (,(string->symbol (concat-strings "make-" (symbol->string name))) ,@members)
- ;; The docstring
- ,(concat-strings "This is the handle to an object of the class " (symbol->string name))
- ;; the body
- ,@body
- (let ,(zip members members)
- (set-type!
- (lambda args
- "This is the docs for the handle"
- (let ((op (eval (car args))))
- (if (procedure? op)
- (eval args)
- (eval (car args)))))
- ,(symbol->keyword name))))
- :constructor)))
-
- (define-macro (-> obj meth . args)
- `(,obj ',meth ,@args))
|