From ef2005e586dcb2d19e1eaced07a7f04fc4e05492 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 5 Mar 2013 07:47:34 -0700 Subject: [PATCH] scribble/manual: add `#:id' option to `defthing' Use this open in the HtDP language documentation in the same way as for `defproc', which fixes the docs for `pi', `e', etc. original commit: 8d03995b628771e529aa56403dbdd29a8e0926d5 --- collects/scribble/private/manual-proc.rkt | 27 ++++++++++++---------- collects/scribblings/scribble/manual.scrbl | 16 +++++++++---- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/collects/scribble/private/manual-proc.rkt b/collects/scribble/private/manual-proc.rkt index 7cac0409..4ea402c9 100644 --- a/collects/scribble/private/manual-proc.rkt +++ b/collects/scribble/private/manual-proc.rkt @@ -913,18 +913,21 @@ ;; ---------------------------------------- -(define-syntax defthing - (syntax-rules () - [(_ #:kind kind id result desc ...) - (with-togetherable-racket-variables - () - () - (*defthing kind - (list (quote-syntax/loc id)) (list 'id) #f - (list (racketblock0 result)) - (lambda () (list desc ...))))] - [(_ id result desc ...) - (defthing #:kind #f id result desc ...)])) +(define-syntax (defthing stx) + (syntax-parse stx + [(_ kind:kind-kw + (~optional (~seq #:id id-expr) + #:defaults ([id-expr #'#f])) + id + result + desc ...) + #'(with-togetherable-racket-variables + () + () + (*defthing kind.kind + (list (or id-expr (quote-syntax/loc id))) (list 'id) #f + (list (racketblock0 result)) + (lambda () (list desc ...))))])) (define-syntax defthing* (syntax-rules () diff --git a/collects/scribblings/scribble/manual.scrbl b/collects/scribblings/scribble/manual.scrbl index 63026fa1..4dfd8615 100644 --- a/collects/scribblings/scribble/manual.scrbl +++ b/collects/scribblings/scribble/manual.scrbl @@ -1040,18 +1040,26 @@ Like @racket[defparam], but the contract on a parameter argument is @racket[boolean?].} -@defform[(defthing maybe-kind id contract-expr-datum pre-flow ...)]{ +@defform/subs[(defthing maybe-kind maybe-id id contract-expr-datum + pre-flow ...) + ([maybe-kind code:blank + (code:line #:kind kind-string-expr)] + [maybe-id code:blank + (code:line #:id id-expr)])]{ Like @racket[defproc], but for a non-procedure binding. -If @racket[#:kind kind-string-expr] is supplied as -@racket[maybe-kind], it is used in the same way as for +If @racket[#:kind kind-string-expr] is supplied, +it is used in the same way as for @racket[defproc], but the default kind is @racket["value"]. +If @racket[#:id id-expr] is supplied, then the result of +@racket[id-expr] is used in place of @racket[id]. + Examples: @codeblock[#:keep-lang-line? #f]|{ #lang scribble/manual -@defthing[moldy-sandwich sandwich?] +@defthing[moldy-sandwich sandwich?]{ Don't eat this. Provided for backwards compatibility. } }|