<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>You need to use define-unit to get this to work: </div><div><br></div><div><div>(define-signature t^ (g))</div><div><br></div><div>(define-unit t@</div><div> ; unit </div><div> (import (prefix config: s^))</div><div> (export t^)</div><div> </div><div> (define (g x)</div><div> (config:f x))</div><div> </div><div> (displayln '(hello world)))</div></div><div><br></div><div><div>(define (f x) (* 2 x)) ;; define the needed dependence </div><div>(define-values/invoke-unit/infer (export t^) (link t@)) ;; infer f is what we import, run unit, export g</div><div>g ;; is available now </div></div><div><br></div><div>In general, units are values like lambdas that come, in principle, with two operations: </div><div><br></div><div> (1) linking </div><div> (2) invoking </div><div><br></div><div>The former satisfies (possibly mutual) dependencies of units without running any code inside of units. The latter runs the code, the last value is returned, like in a lambda. </div><div><br></div><div>Here is another way to run with a prefix: </div><div><br></div><div><div>(define-signature s^ (f))</div><div>(define-signature t^ (g))</div><div><br></div><div>(define t@</div><div> (unit </div><div> (import (prefix config: s^))</div><div> (export t^)</div><div> </div><div> (define (g x)</div><div> (config:f x))</div><div> </div><div> (displayln '(hello world))))</div><div><br></div><div>(define s@</div><div> (unit</div><div> (import)</div><div> (export s^)</div><div> </div><div> (define (f y)</div><div> y)))</div><div><br></div><div><div>(define main-2@</div><div> (compound-unit </div><div> (import)</div><div> (export t)</div><div> (link</div><div> (((s : s^)) s@)</div><div> (((t : t^)) t@ s))))</div><div><br></div><div>(invoke-unit main-2@)</div></div></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><br><div><div>On Feb 20, 2014, at 9:33 PM, Paul Meier wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div><div><div><div><div><div><div>Hi friends,<br><br></div>Just a quick question on using Units -- I have one unit that imports a signature and appends a prefix, a la<br><br></div> (define-unit my-unit@<br>
</div> (import (prefix config: config-signature^))<br></div> (export my-unit^)<br></div><div> ;; implements my-unit^...<br></div><div> )<br><br></div>But when I attempt to invoke this after invoking a unit satisfying the dependency signature (above, `config-signature`), I get errors that it can't locate identifiers from the imported signatures.<br>
<br>I suspect this is to do with the fact that I'm invoking the dependency at the toplevel using define-values/invoke-unit/infer<span class=""></span><span class="">, per the Racket Guide, but a perusal of the Racket Reference suggests another method of invocation might be more suitable, since define-values is just exporting bindings to the global namespace, and here I'm referring to them by a prefixed form.<br>
<br></span></div><span class="">That said, I'm not entirely clear on what what value the `invoke-units` syntax returns, or what side effects invocation of a unit even <i>does</i> from reading <a href="http://docs.racket-lang.org/reference/invokingunits.html#%28form._%28%28lib._racket%2Funit..rkt%29._invoke-unit%29%29">the docs</a> (if it isn't defining bindings).<br>
<br></span></div><span class="">Any help would be appreciated! Thanks ^_^<br><br></span></div><span class="">-Paul<br></span><br></div>
____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>