Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

28 righe
898 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. `(set-type
  6. (define
  7. ;; The function definition
  8. (,(string->symbol (concat-strings "make-" (symbol->string name))) @members)
  9. ;; The docstring
  10. ,(concat-strings "This is the handle to an object of the class " (symbol->string name))
  11. ;; the body
  12. @body
  13. (let ,(zip members members)
  14. (set-type
  15. (lambda (:rest args)
  16. "This is the docs for the handle"
  17. (let ((op (eval (first args))))
  18. (if (callable? op)
  19. (eval args)
  20. (eval (first args)))))
  21. ,(symbol->keyword name))))
  22. :constructor)))
  23. (define-syntax (-> obj meth :rest args)
  24. `(,obj ',meth @args))