[plt-scheme] multiple units with identical signatures

From: Anthony Cowley (acowley at seas.upenn.edu)
Date: Mon Nov 2 19:15:55 EST 2009

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@
  (export page^)
  (define (respond) "I'm a page!"))

(define-signature info^ (respond))
(define-unit info@
  (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)
      ((string=? x "~page") (page:respond))
      ((string=? x "~info") (info:respond))
      (else (error "Couldn't dispatch" x)))))

(define-compound-unit together@
  (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")))



Posted on the users mailing list.