您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

24 行
854 B

  1. (define-syntax (define-class name-and-members :rest body)
  2. "Macro for creating simple classes."
  3. (let ((name (first name-and-members))
  4. (members (rest name-and-members)))
  5. `(define
  6. ;; The function definition
  7. (,(string->symbol (concat-strings "make-" (symbol->string name))) @members)
  8. ;; The docstring
  9. ,(concat-strings "This is the handle to an object of the class " (symbol->string name))
  10. ;; the body
  11. (let ,(zip members members)
  12. @body
  13. (set-type
  14. (lambda (:rest args)
  15. "This is the docs for the handle"
  16. (let ((op (eval (first args))))
  17. (if (callable? op)
  18. (eval args)
  19. (eval (first args)))))
  20. ,(symbol->keyword name))))))
  21. (define-syntax (-> obj meth :rest args)
  22. `(,obj ',meth @args))