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.
This commit is contained in:
Matthew Flatt 2013-03-05 07:47:34 -07:00
parent a8e99fa572
commit 8d03995b62
4 changed files with 29 additions and 17 deletions

View File

@ -100,7 +100,7 @@ tests to run:
(defproc #:id [ex (datum->syntax c 'ex)] (defproc #:id [ex (datum->syntax c 'ex)]
(ex args ...) range w ...)))] (ex args ...) range w ...)))]
[(defthing name range w ...) [(defthing name range w ...)
#'(lambda (c) (defthing name range w ...))])) #'(lambda (c) (defthing #:id (datum->syntax c 'name) name range w ...))]))
(map rewrite-one-def defs names)) (map rewrite-one-def defs names))

View File

@ -913,18 +913,21 @@
;; ---------------------------------------- ;; ----------------------------------------
(define-syntax defthing (define-syntax (defthing stx)
(syntax-rules () (syntax-parse stx
[(_ #:kind kind id result desc ...) [(_ kind:kind-kw
(with-togetherable-racket-variables (~optional (~seq #:id id-expr)
#:defaults ([id-expr #'#f]))
id
result
desc ...)
#'(with-togetherable-racket-variables
() ()
() ()
(*defthing kind (*defthing kind.kind
(list (quote-syntax/loc id)) (list 'id) #f (list (or id-expr (quote-syntax/loc id))) (list 'id) #f
(list (racketblock0 result)) (list (racketblock0 result))
(lambda () (list desc ...))))] (lambda () (list desc ...))))]))
[(_ id result desc ...)
(defthing #:kind #f id result desc ...)]))
(define-syntax defthing* (define-syntax defthing*
(syntax-rules () (syntax-rules ()

View File

@ -1040,18 +1040,26 @@ Like @racket[defparam], but the contract on a parameter argument is
@racket[boolean?].} @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. Like @racket[defproc], but for a non-procedure binding.
If @racket[#:kind kind-string-expr] is supplied as If @racket[#:kind kind-string-expr] is supplied,
@racket[maybe-kind], it is used in the same way as for it is used in the same way as for
@racket[defproc], but the default kind is @racket["value"]. @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: Examples:
@codeblock[#:keep-lang-line? #f]|{ @codeblock[#:keep-lang-line? #f]|{
#lang scribble/manual #lang scribble/manual
@defthing[moldy-sandwich sandwich?] @defthing[moldy-sandwich sandwich?]{
Don't eat this. Provided for backwards compatibility. Don't eat this. Provided for backwards compatibility.
} }
}| }|

View File

@ -3,6 +3,7 @@ Added module-compiled-cross-phase-persistent?
Added 'so-mode mode for system-type Added 'so-mode mode for system-type
ffi/unsafe: changed ffi-lib to use (system-type 'so-mode) ffi/unsafe: changed ffi-lib to use (system-type 'so-mode)
slideshow/balloon: add balloon-enable-3d slideshow/balloon: add balloon-enable-3d
scribble/manual: added #:id option to defthing
Version 5.3.3.6 Version 5.3.3.6
Added "phase-collapse" module inference and instantiation Added "phase-collapse" module inference and instantiation