From 35575378d8e4e6c2c5d28c802c10aac24358d28d Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Fri, 1 Aug 2008 18:48:48 +0000 Subject: [PATCH] Add shorthands for define-require-syntax and define-provide-syntax. Document shorthands. svn: r11025 --- collects/scheme/provide-syntax.ss | 14 ++++++--- collects/scheme/require-syntax.ss | 12 ++++++-- collects/scribblings/reference/syntax.scrbl | 32 ++++++++++++++------- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/collects/scheme/provide-syntax.ss b/collects/scheme/provide-syntax.ss index 3499bc1f6f..13b7608730 100644 --- a/collects/scheme/provide-syntax.ss +++ b/collects/scheme/provide-syntax.ss @@ -1,6 +1,6 @@ #lang scheme/base -(provide define-provide-syntax ) +(provide define-provide-syntax) (require (for-syntax scheme/base scheme/provide-transform)) @@ -15,7 +15,13 @@ (define-syntax (define-provide-syntax stx) (syntax-case stx () [(_ id proc) - (symbol? (syntax-e #'id)) - #'(define-syntax id + (identifier? #'id) + (syntax/loc stx + (define-syntax id (let ([cert (syntax-local-provide-certifier)]) - (make-provide-macro cert proc)))])) + (make-provide-macro cert proc))))] + [(_ (id . args) . body) + (identifier? #'id) + (syntax/loc stx + (define-provide-syntax id + (lambda args . body)))])) diff --git a/collects/scheme/require-syntax.ss b/collects/scheme/require-syntax.ss index 723dbf1590..678a36c16b 100644 --- a/collects/scheme/require-syntax.ss +++ b/collects/scheme/require-syntax.ss @@ -15,7 +15,13 @@ (define-syntax (define-require-syntax stx) (syntax-case stx () [(_ id proc) - (symbol? (syntax-e #'id)) - #'(define-syntax id + (identifier? #'id) + (syntax/loc stx + (define-syntax id (let ([cert (syntax-local-require-certifier)]) - (make-require-macro cert proc)))])) + (make-require-macro cert proc))))] + [(_ (id . args) . body) + (identifier? #'id) + (syntax/loc stx + (define-require-syntax id + (lambda args . body)))])) diff --git a/collects/scribblings/reference/syntax.scrbl b/collects/scribblings/reference/syntax.scrbl index 3e8f2c2dfc..0a9f5c119f 100644 --- a/collects/scribblings/reference/syntax.scrbl +++ b/collects/scribblings/reference/syntax.scrbl @@ -1587,15 +1587,21 @@ bound (at @tech{phase level} 1).} @note-lib-only[scheme/require-syntax] -@defform[(define-require-syntax id proc-expr)]{ +@defform*[[(define-require-syntax id expr) + (define-require-syntax (id args ...) body ...+)]]{ -Like @scheme[define-syntax], but for a @scheme[require] sub-form. The -@scheme[proc-expr] must produce a procedure that accepts and returns a -syntax object representing a @scheme[require] sub-form. +The first form is like @scheme[define-syntax], but for a +@scheme[require] sub-form. The @scheme[proc-expr] must produce a +procedure that accepts and returns a syntax object representing a +@scheme[require] sub-form. This form expands to @scheme[define-syntax] with a use of @scheme[make-require-transformer]; see @secref["require-trans"] for -more information.} +more information. + +The second form is a shorthand the same as for @scheme[define-syntax]; it +expands to a definition of the first form where the @scheme[expr] is a +@scheme[lambda] form.} @; ---------------------------------------------------------------------- @@ -1603,15 +1609,21 @@ more information.} @note-lib-only[scheme/provide-syntax] -@defform[(define-provide-syntax id proc-expr)]{ +@defform[(define-provide-syntax id expr) + (define-provide-syntax (id args ...) body ...+)]{ -Like @scheme[define-syntax], but for a @scheme[provide] sub-form. The -@scheme[proc-expr] must produce a procedure that accepts and returns a -syntax object representing a @scheme[provide] sub-form. +The first form is like @scheme[define-syntax], but for a +@scheme[provide] sub-form. The @scheme[proc-expr] must produce a +procedure that accepts and returns a syntax object representing a +@scheme[provide] sub-form. This form expands to @scheme[define-syntax] with a use of @scheme[make-provide-transformer]; see @secref["provide-trans"] for -more information.} +more information. + +The second form is a shorthand the same as for @scheme[define-syntax]; it +expands to a definition of the first form where the @scheme[expr] is a +@scheme[lambda] form.} @;------------------------------------------------------------------------ @section[#:tag "begin"]{Sequencing: @scheme[begin], @scheme[begin0], and @scheme[begin-for-syntax]}