From b953b448bae8c6e742239347db81a1f2edabdc41 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 21 Feb 2008 13:30:25 +0000 Subject: [PATCH] expose struct:struct-info svn: r8753 --- collects/scheme/private/struct-info.ss | 24 ++++++++++----------- collects/scribblings/reference/struct.scrbl | 12 +++++++++-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/collects/scheme/private/struct-info.ss b/collects/scheme/private/struct-info.ss index 2f15551198..16e38f8f47 100644 --- a/collects/scheme/private/struct-info.ss +++ b/collects/scheme/private/struct-info.ss @@ -7,9 +7,10 @@ (#%provide make-struct-info struct-info? - extract-struct-info) + extract-struct-info + struct:struct-info) - (define-values (struct:struct-info create-struct-info struct-info-rec? + (define-values (struct:struct-info make-struct-info struct-info-rec? struct-info-ref struct-info-set!) (make-struct-type 'struct-info #f 1 0 #f @@ -18,16 +19,15 @@ (raise-syntax-error #f "identifier for static struct-type information cannot be used as an expression" - stx)))) - - (define-values (make-struct-info) - (lambda (proc) - (if (and (procedure? proc) - (procedure-arity-includes? proc 0)) - (create-struct-info proc) - (raise-type-error 'make-struct-info - "procedure (arity 0)" - proc)))) + stx)) + null + (lambda (proc info) + (if (and (procedure? proc) + (procedure-arity-includes? proc 0)) + proc + (raise-type-error 'make-struct-info + "procedure (arity 0)" + proc))))) (define-values (extract-struct-info) (lambda (si) diff --git a/collects/scribblings/reference/struct.scrbl b/collects/scribblings/reference/struct.scrbl index 743ba7d28b..1ba88a3231 100644 --- a/collects/scribblings/reference/struct.scrbl +++ b/collects/scribblings/reference/struct.scrbl @@ -361,8 +361,8 @@ information can be used during the expansion of other expressions via @scheme[syntax-local-value]. For example, the @scheme[define-struct] variant for subtypes uses the -base type name @scheme[t] to find the variable -@scheme[struct@scheme[:t]] containing the base type's descriptor; it +base type name @scheme[_t] to find the variable +@schemeidfont{struct:}@scheme[_t] containing the base type's descriptor; it also folds the field accessor and mutator information for the base type into the information for the subtype. As another example, the @scheme[match] form uses a type name to find the predicates and field @@ -449,3 +449,11 @@ form.} Extracts the list form of the structure type information represented by @scheme[v].} + +@defthing[struct:struct-info struct-type?]{ + +The @tech{structure type descriptor} for the structure type returned +by @scheme[make-struct-info]. This @tech{structure type descriptor} is +mostly useful for creating structure subtypes. The structure type +includes a guard that checks an instance's first field in the same way +as @scheme[make-struct-info].}