[plt-scheme] Unit won't Import

From: Anthony Cowley (acowley at seas.upenn.edu)
Date: Thu Aug 6 14:56:01 EDT 2009

On Thu, Aug 6, 2009 at 2:14 PM, Synx<plt at synx.us.to> wrote:
> In my larger
> project I have recursive dependencies between units and thus can't pick
> a particular order to 'define-values/invoke-unit/infer them in.

I didn't address this point earlier. If your units are evaluating
their dependencies as part of their top-level evaluation, then mutual
recursion could be problematic, but this is not restricted to the
Units mechanism. If, on the other hand, you are defining functions in
terms of dependencies, then you probably do not have a problem. Here
is a silly example...


#lang scheme

(define-signature even^

(define-signature odd^

(define-unit even@
  (import odd^)
  (export even^)
  (define (my-even? x) (if (= x 0) #t (my-odd? (- x 1)))))

(define-unit odd@
  (import even^)
  (export odd^)
  (define (my-odd? x) (if (= x 0) #f (my-even? (- x 1)))))

(define-compound-unit/infer num-checker@
  (export E O)
  (link (((E : even^)) even@ O)
        (((O : odd^)) odd@ E)))

(define-values/invoke-unit/infer num-checker@)

(my-even? 12)
(my-odd? 14)

Posted on the users mailing list.