[plt-scheme] signed unit syntax

From: David J. Neu (djneu at att.net)
Date: Wed Oct 27 15:12:33 EDT 2004

Hi all,

I'm trying to get a handle around some of the syntax for signed units
and have attached a simple toy example to show where I'm stuck.

In the example, there are two units one that performs some simple
computation and one that displays formatted output.  I have a function
called _output-sqrt-sum-squares_ which consumes the values to submit
to the computation and tries to run the compuation and output the
result.

The error I'm getting is
> reference to undefined identifier: output
Clearly a lack of understanding on my part.

Thanks in advance for any help!

Cheers,
David


(require (lib "unitsig.ss"))
 
(define-signature c^ (computation))

(define-signature o^ (output))

(define sqrt-sum-squares@
  (unit/sig c^
    
    (import)
    
    (define square
      (lambda (x) (* x x)))
    
    (define computation
      (lambda (x y)
        (+ (square x) (square y))))))

(define simple-output@
  (unit/sig o^
    
    (import)
    
    (define output
      (lambda (v)
        (printf "value = ~a~n" v)))))

(define output-sqrt-sum-squares
  (lambda (x y)
    (invoke-unit/sig
     (compound-unit/sig
       (import)
       (link
        (COMP : c^ (sqrt-sum-squares@))
        (OUT : o^ (simple-output@)))
       (export (open COMP) (open OUT))))
    (output (distance x y)))) ; *** I don't know how to make this procedure call ***

(output-sqrt-sum-squares 2 4)


Posted on the users mailing list.