[plt-scheme] multiple units with identical signatures
On Mon, Nov 2, 2009 at 6:31 PM, Synx <plt at synx.us.to> wrote:
> If two units have the same signature, I don't see how I could import
> them both. If two units have identical signatures, by different names,
> that seems to work, but it fails on linkage.
How's this,
----------------
#lang scheme
(define-signature page^ (respond))
(define-unit page@
(import)
(export page^)
(define (respond) "I'm a page!"))
(define-signature info^ (respond))
(define-unit info@
(import)
(export info^)
(define (respond) "I'm informative!"))
(define-signature top^ (run))
(define-unit top@
(import (prefix page: page^)
(prefix info: info^))
(export top^)
(define (run x)
(cond
((string=? x "~page") (page:respond))
((string=? x "~info") (info:respond))
(else (error "Couldn't dispatch" x)))))
(define-compound-unit together@
(import)
(export T)
(link (((P : page^)) page@)
(((I : info^)) info@)
(((T : top^)) top@ P I)))
(define (main)
(define-values/invoke-unit/infer together@)
(cons (run "~page")
(run "~info")))
----------------
Anthony