Use unit-binding, and link to the section that details handling first-class
units in more length. svn: r13569
This commit is contained in:
parent
5b0ceb3db4
commit
4f12a1e364
|
@ -269,7 +269,7 @@ This unit has no imports, so we can always invoke it:
|
||||||
|
|
||||||
@; ----------------------------------------
|
@; ----------------------------------------
|
||||||
|
|
||||||
@section{First-Class Units}
|
@section[#:tag "firstclassunits"]{First-Class Units}
|
||||||
|
|
||||||
The @scheme[define-unit] form combines @scheme[define] with a
|
The @scheme[define-unit] form combines @scheme[define] with a
|
||||||
@scheme[unit] form, similar to the way that @scheme[(define (f x)
|
@scheme[unit] form, similar to the way that @scheme[(define (f x)
|
||||||
|
@ -577,9 +577,9 @@ scheme
|
||||||
|
|
||||||
Since the result of the @scheme[unit/c] combinator is a new unit value
|
Since the result of the @scheme[unit/c] combinator is a new unit value
|
||||||
which has not been defined with @scheme[define-unit] or another similar
|
which has not been defined with @scheme[define-unit] or another similar
|
||||||
form, we run into problems with signature inference. We see this below in the
|
form, we run into problems with signature inference. The section
|
||||||
use of @scheme[define-compound-unit] instead of @scheme[define-compound-unit/infer]
|
@secref{firstclassunits} lists options that we can use to handle the
|
||||||
to link the two units.
|
resulting values.
|
||||||
|
|
||||||
@interaction[
|
@interaction[
|
||||||
#:eval toy-eval
|
#:eval toy-eval
|
||||||
|
@ -594,11 +594,14 @@ to link the two units.
|
||||||
'wrapped-toy-store-unit
|
'wrapped-toy-store-unit
|
||||||
'top-level
|
'top-level
|
||||||
(list (make-srcloc 'top-level #f #f #f #f) "wrapped-toy-store@"))))
|
(list (make-srcloc 'top-level #f #f #f #f) "wrapped-toy-store@"))))
|
||||||
(define-compound-unit checked-toy-store+factory@
|
(define-unit-binding protected-toy-store@
|
||||||
|
wrapped-toy-store@
|
||||||
|
(import toy-factory^)
|
||||||
|
(export toy-store^))
|
||||||
|
(define-compound-unit/infer checked-toy-store+factory@
|
||||||
(import)
|
(import)
|
||||||
(export F S)
|
(export toy-factory^ toy-store^)
|
||||||
(link [((F : toy-factory^)) store-specific-factory@ S]
|
(link store-specific-factory@ protected-toy-store@))
|
||||||
[((S : toy-store^)) wrapped-toy-store@ F]))
|
|
||||||
(define-values/invoke-unit/infer checked-toy-store+factory@)
|
(define-values/invoke-unit/infer checked-toy-store+factory@)
|
||||||
(store-color)
|
(store-color)
|
||||||
(stock! 'a)
|
(stock! 'a)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user