Skip to content

Commit bb1ef38

Browse files
shhyousorawee
authored andcommitted
Refine the grammar of field-name in defstruct.
The defstruct[*] form does support field options. Therefore use the same grammar as [define-]struct in the documentation.
1 parent 07cb0aa commit bb1ef38

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scribble-doc/scribblings/scribble/manual.scrbl

+10-6
Original file line numberDiff line numberDiff line change
@@ -1467,16 +1467,20 @@ Examples:
14671467

14681468

14691469
@deftogether[(
1470-
@defform[ (defstruct* maybe-link struct-name ([field-name contract-expr-datum] ...)
1470+
@defform[ (defstruct* maybe-link struct-name ([field contract-expr-datum] ...)
14711471
maybe-mutable maybe-non-opaque maybe-constructor
14721472
pre-flow ...)]
1473-
@defform/subs[ (defstruct maybe-link struct-name ([field-name contract-expr-datum] ...)
1473+
@defform/subs[ (defstruct maybe-link struct-name ([field contract-expr-datum] ...)
14741474
maybe-mutable maybe-non-opaque maybe-constructor
14751475
pre-flow ...)
14761476
([maybe-link code:blank
14771477
(code:line #:link-target? link-target?-expr)]
14781478
[struct-name id
14791479
(id super-id)]
1480+
[field field-id
1481+
(field-id field-option ...)]
1482+
[field-option #:mutable
1483+
#:auto]
14801484
[maybe-mutable code:blank
14811485
#:mutable]
14821486
[maybe-non-opaque code:blank
@@ -1498,18 +1502,18 @@ Examples:
14981502
An example using @racket[defstruct]:
14991503
@codeblock[#:keep-lang-line? #f]|{
15001504
#lang scribble/manual
1501-
@defstruct[sandwich ([protein ingredient?] [sauce ingredient?])]{
1505+
@defstruct[sandwich ([(protein #:mutable) ingredient?] [sauce ingredient?])]{
15021506
A structure type for sandwiches. Sandwiches are a pan-human foodstuff
15031507
composed of a partially-enclosing bread material and various
1504-
ingredients.
1508+
ingredients. The @racketid[protein] field is mutable.
15051509
}
15061510
}|
15071511
@doc-render-examples[
15081512
@defstruct[#:link-target? #f
1509-
sandwich ([protein ingredient?] [sauce ingredient?])]{
1513+
sandwich ([(protein #:mutable) ingredient?] [sauce ingredient?])]{
15101514
A structure type for sandwiches. Sandwiches are a pan-human foodstuff
15111515
composed of a partially-enclosing bread material and various
1512-
ingredients.
1516+
ingredients. The @racketid[protein] field is mutable.
15131517
}]
15141518

15151519
Additionally, an example using @racket[defstruct*]:

0 commit comments

Comments
 (0)