allow defmacros to have docstrings
* module/ice-9/boot-9.scm (define-macro, defmacro): Add the ability to have a docstring. * module/ice-9/documentation.scm (object-documentation): Remove references to defmacro? and macro?. Since we store the transformation procedure as the binding, we can get docs from the procedure directly. * module/ice-9/psyntax-pp.scm: Regenerate. * module/ice-9/psyntax.scm (put-global-definition-hook): Take the type and the value separately, so we can set the variable to the procedure, while keeping the *sc-expander* to be the "binding object". (global-extend): Pass type and val separately.
This commit is contained in:
parent
b3501b8043
commit
97ce9dbf21
4 changed files with 33 additions and 27 deletions
|
|
@ -209,13 +209,20 @@
|
|||
|
||||
(define-syntax define-macro
|
||||
(lambda (x)
|
||||
"Define a defmacro."
|
||||
(syntax-case x ()
|
||||
((_ (macro . args) . body)
|
||||
(syntax (define-macro macro (lambda args . body))))
|
||||
((_ macro transformer)
|
||||
((_ (macro . args) doc body1 body ...)
|
||||
(string? (syntax-object->datum (syntax doc)))
|
||||
(syntax (define-macro macro doc (lambda args body1 body ...))))
|
||||
((_ (macro . args) body ...)
|
||||
(syntax (define-macro macro #f (lambda args body ...))))
|
||||
((_ macro doc transformer)
|
||||
(or (string? (syntax-object->datum (syntax doc)))
|
||||
(not (syntax-object->datum (syntax doc))))
|
||||
(syntax
|
||||
(define-syntax macro
|
||||
(lambda (y)
|
||||
doc
|
||||
(syntax-case y ()
|
||||
((_ . args)
|
||||
(let ((v (syntax-object->datum (syntax args))))
|
||||
|
|
@ -223,9 +230,13 @@
|
|||
|
||||
(define-syntax defmacro
|
||||
(lambda (x)
|
||||
"Define a defmacro, with the old lispy defun syntax."
|
||||
(syntax-case x ()
|
||||
((_ macro args . body)
|
||||
(syntax (define-macro macro (lambda args . body)))))))
|
||||
((_ macro args doc body1 body ...)
|
||||
(string? (syntax-object->datum (syntax doc)))
|
||||
(syntax (define-macro macro doc (lambda args body1 body ...))))
|
||||
((_ macro args body ...)
|
||||
(syntax (define-macro macro #f (lambda args body ...)))))))
|
||||
|
||||
(provide 'defmacro)
|
||||
|
||||
|
|
|
|||
|
|
@ -195,12 +195,6 @@ OBJECT can be a procedure, macro or any object that has its
|
|||
`documentation' property set."
|
||||
(or (and (procedure? object)
|
||||
(proc-doc object))
|
||||
(and (defmacro? object)
|
||||
(proc-doc (defmacro-transformer object)))
|
||||
(and (macro? object)
|
||||
(let ((transformer (macro-transformer object)))
|
||||
(and transformer
|
||||
(proc-doc transformer))))
|
||||
(object-property object 'documentation)
|
||||
(and (program? object)
|
||||
(program-documentation object))
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -338,16 +338,17 @@
|
|||
((_) (gensym))))
|
||||
|
||||
(define put-global-definition-hook
|
||||
(lambda (symbol binding)
|
||||
(lambda (symbol type val)
|
||||
(let* ((module (current-module))
|
||||
(v (or (module-variable module symbol)
|
||||
(let ((v (make-variable (gensym))))
|
||||
(let ((v (make-variable val)))
|
||||
(module-add! module symbol v)
|
||||
v))))
|
||||
(if (not (variable-bound? v))
|
||||
(variable-set! v (gensym)))
|
||||
(variable-set! v val))
|
||||
;; Properties are tied to variable objects
|
||||
(set-object-property! v '*sc-expander* binding))))
|
||||
(set-object-property! v '*sc-expander*
|
||||
(make-binding type val)))))
|
||||
|
||||
(define remove-global-definition-hook
|
||||
(lambda (symbol)
|
||||
|
|
@ -604,7 +605,7 @@
|
|||
|
||||
(define global-extend
|
||||
(lambda (type sym val)
|
||||
(put-global-definition-hook sym (make-binding type val))))
|
||||
(put-global-definition-hook sym type val)))
|
||||
|
||||
|
||||
;;; Conceptually, identifiers are always syntax objects. Internally,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue