[plt-scheme] Linking units with multiple dependencies

From: Anthony Cowley (acowley at seas.upenn.edu)
Date: Sun Dec 20 11:16:01 EST 2009

Here's an example with no use of inference. At the risk of sounding
like a broken record, I always advise hiding this tricky syntax in
your own applications using any means necessary. I try to structure
large applications around Units, then have helper functions or macros
that do the final assembly of all the dependencies. The DSTM system
uses lots of Units, but primarily hinges off of the selection of an
inter-process messaging system. So I have a setup-dstm macro that
takes a messaging unit (e.g. TCP, UDP, Ports) and then does a lot of
linking before invoking a compound unit to pull the needed names into
scope. I always trip over this syntax, though, so I really make an
effort to keep it in library code.

Anthony

#lang scheme

(define-signature a^ (x))
(define-signature b^ (y))
(define-signature c^ (z))
(define-unit a@
  (import)
  (export a^)
  (define x 2))
(define-unit b@
  (import)
  (export b^)
  (define y 3))
(define-unit c@
  (import a^ b^)
  (export c^)
  (define z (+ x y)))
(define-compound-unit a+b+c@
  (import)
  (export C)
  (link (((A : a^)) a@)
        (((B : b^)) b@)
        (((C : c^ )) c@ A B)))

(define-values/invoke-unit
  a+b+c@
  (import)
  (export c^))

z


On Sun, Dec 20, 2009 at 3:13 AM, Thomas Chust <chust at web.de> wrote:
> Hello,
>
> maybe I am really too dumb to find the right tools in the documentation,
> but I can't figure out how to create a compound unit with multiple other
> units providing its imported interfaces in case the automatic inference
> of linkage information cannot be used.
>
> Suppose I have something like
>
>  (define-signature a^
>    ())
>
>  (define-signature b^
>    ())
>
>  (define-signature c^
>    ())
>
>  (define-unit a@
>    (import)
>    (export a^))
>
>  (define-unit b@
>    (import)
>    (export b^))
>
>  (define-unit c@
>    (import a^ b^)
>    (export c^))
>
> Using inference of linkage information I can now define
>
>  (define-compound-unit/infer a+b+c@
>    (import)
>    (export c^)
>    (link a@ b@ c@))
>
> But is there some way I can use compound-unit (or a similar form without
> the /infer suffix) to the same effect? As far as I can see this is
> impossible, because compound-unit allows only for a single import per
> unit to be satisfied through a linkage declaration — or am I overlooking
> something here?
>
> Ciao,
> Thomas
>
>
> --
> When C++ is your hammer, every problem looks like your thumb.
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.