Update docs & tests for struct constructor options

This commit is contained in:
Asumu Takikawa 2015-12-07 01:58:57 -05:00
parent 796af399bf
commit 7f05dc6731
3 changed files with 26 additions and 1 deletions

View File

@ -382,7 +382,9 @@ those functions.
(struct maybe-type-vars name-spec ([f : t] ...) options ...)
([maybe-type-vars code:blank (v ...)]
[name-spec name (code:line name parent)]
[options #:transparent #:mutable #:prefab])]{
[options #:transparent #:mutable #:prefab
(code:line #:constructor-name constructor-id)
(code:line #:extra-constructor-name constructor-id)])]{
Defines a @rtech{structure} with the name @racket[name], where the
fields @racket[f] have types @racket[t], similar to the behavior of @|struct-id|
from @racketmodname[racket/base].

View File

@ -0,0 +1,8 @@
#;
(exn-pred "define-struct: expected typed structure type options")
#lang typed/racket/base
(define-struct foo ()
;; can't have both of these
#:constructor-name foo-cn
#:extra-constructor-name foo-ecn)

View File

@ -0,0 +1,15 @@
#lang typed/racket/base
;; Tests for constructor options for struct
(struct s1 ([x : Integer]) #:constructor-name cons-s1)
(define-struct s2 ([x : Integer]) #:constructor-name cons-s2)
(struct s3 ([x : Integer]) #:extra-constructor-name cons-s3)
(define-struct s4 ([x : Integer]) #:extra-constructor-name cons-s4)
(cons-s1 1)
(cons-s2 2)
(s3 3)
(cons-s3 3)
(s4 4)
(cons-s4 4)