1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Convert (ice-9 session) to use hygienic macros.

* module/ice-9/session.scm (help): Convert to syntax-rules. Also move
  most of the body into help-internal; help messages should not be
  displayed at macro-expansion time.
  (help-internal): New procedure.
This commit is contained in:
Chris K. Jester-Young 2013-10-28 10:17:03 -04:00
parent 5b491e4f28
commit 0e07c94ef1

View file

@ -78,19 +78,19 @@ handlers, potentially falling back on the normal behavior for `help'."
;;; Documentation ;;; Documentation
;;; ;;;
(define-macro (help . exp) (define-syntax help
"(help [NAME]) (syntax-rules ()
"(help [NAME])
Prints useful information. Try `(help)'." Prints useful information. Try `(help)'."
(cond ((not (= (length exp) 1)) ((_ name) (help-internal 'name))
(help-usage) ((_ ...) (help-usage))))
'(begin))
((not (provided? 'regex)) (define (help-internal name)
(cond ((not (provided? 'regex))
(display "`help' depends on the `regex' feature. (display "`help' depends on the `regex' feature.
You don't seem to have regular expressions installed.\n") You don't seem to have regular expressions installed.\n"))
'(begin))
(else (else
(let ((name (car exp)) (let ((not-found (lambda (type x)
(not-found (lambda (type x)
(simple-format #t "No ~A found for ~A\n" (simple-format #t "No ~A found for ~A\n"
type x)))) type x))))
(cond (cond
@ -143,8 +143,7 @@ You don't seem to have regular expressions installed.\n")
;; unrecognized ;; unrecognized
(else (else
(help-usage))) (help-usage)))))))
'(begin)))))
(define (module-filename name) ; fixme: better way? / done elsewhere? (define (module-filename name) ; fixme: better way? / done elsewhere?
(let* ((name (map symbol->string name)) (let* ((name (map symbol->string name))