The define-signature form allows define-values and define-values-for-export 
forms in its body. According to the documentation the define-values form should 
prefix any unit that imports the signature, and define-values-for-export should 
suffix any unit that exports the signature, but the actual behavior doesn't 
seem to match the documentation.

I can define the following signature and unit:

(define-signature x^
  ((define-values-for-export (x) 5)
   x
   ))

(define x@
  (unit (import)
        (export x^)))

(define-values/invoke-unit x@ (import) (export x^))

This makes sense to me, because the definition for x is available within the x@ 
unit, but it must also be listed in the signature by name in order to actually 
export the value, so that x is defined when invoking the unit with 
define-values/invoke-unit.

What confuses me is that I can also define the following signature and unit:

(define-signature y^
  ((define-values (y) 5)))

(define y@
  (unit (import)
        (export y^)))

(define-values/invoke-unit y@ (import) (export y^))

This does introduce a binding for y with the value 5, but I don't understand 
why. Since the y^ signature is being exported instead of imported I expected 
that the value of y should not be available in the y@ unit, and furthermore 
there is no need to declare y in the signature as a variable which the unit 
must define. So why is it the case that this unit defines and exports the value 
of y, when according to the documentation this shouldn't happen.

Thanks
Dan
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to