Add error checking for contracted form, also added documentation in reference

svn: r13135
This commit is contained in:
Stevie Strickland 2009-01-15 00:42:49 +00:00
parent 4ca79e31ff
commit dbe366c6a0
3 changed files with 21 additions and 2 deletions

View File

@ -3,7 +3,7 @@
(provide only except prefix rename tag
import export init-depend link
extends)
extends contracted)
(define-syntax-rule (define-syntax-for-error name message)
(define-syntax name
@ -34,3 +34,5 @@
"misuse of compound-unit keyword")
(define-syntax-for-error extends
"misuse of define-signature keyword")
(define-syntax-for-error contracted
"misuse of define-signature keyword")

View File

@ -17,7 +17,7 @@
(provide define-signature-form struct open
define-signature provide-signature-elements
only except rename import export prefix link tag init-depend extends
only except rename import export prefix link tag init-depend extends contracted
unit?
(rename :unit unit) define-unit
compound-unit define-compound-unit compound-unit/infer define-compound-unit/infer
@ -252,6 +252,13 @@
val-defs
stx-defs
(append (syntax->list #'(z ...)) ctcs)))
((x . z)
(and (identifier? #'x)
(module-identifier=? #'x #'contracted))
(raise-syntax-error
'define-signature
"expected a list of [id contract] pairs after the contracted keyword"
(car sig-exprs)))
((x . y)
(and (identifier? #'x)
(or (module-identifier=? #'x #'define-values)

View File

@ -160,6 +160,7 @@ the corresponding import. Each @scheme[tagged-sig-id] in an
[sig-elem
id
(contracted [id contract] ...)
(define-syntaxes (id ...) expr)
(define-values (value-id ...) expr)
(open sig-spec)
@ -175,6 +176,15 @@ of bindings for import or export:
@scheme[id]. That is, @scheme[id] is available for use in units
importing the signature, and @scheme[id] must be defined by units
exporting the signature.}
@item{Each @scheme[contracted] form in a signature declaration means
that a unit exporting the signature must supply a variable definition
for each @scheme[id] in that form. If the signature is imported, then
uses of @scheme[id] inside the unit are protected by the appropriate
contracts using the unit as the negative blame. If the signature is
exported, then the exported values are protected by the appropriate
contracts which use the unit as the positive blame, but internal uses
of the exported identifiers are not protected.}
@item{Each @scheme[define-syntaxes] form in a signature declaration
introduces a macro to that is available for use in any unit that