
@m4burns has joined the channel

if there’s anyone who uses units out there, I’m wondering if you have a workaround (or just an explanation) for the following error:
#lang racket
(define-signature sig^ (do-x do-y))
(define-unit a-unit@
(import)
(export sig^)
(define (do-x) 2)
(define (do-y) 2))
(define-unit b-unit@
(import sig^)
(export (rename sig^ (do-x/wrapped do-x)))
(define (do-x/wrapped) (+ 1 (do-x))))
returns:
main.rkt:11:0: define-unit: import do-y is exported
in: (define-unit b-unit@ (import sig^) (export (rename sig^ (do-x/wrapped do-x))) (define (do-x/wrapped) (+ 1 (do-x))))

I could define-values
the re-exported identifiers within the body of b-unit@
, but doing that for each identifier is kind of a joykill

and it seems unnatural to me that you can’t just pass through an identifier to satisfy the signature

Unit imports and exports are variables, as opposed to values. So, re-exporting an import would mean aliasing the import variable as the export variable. With modules, that kind of aliasing is no problem, because dependencies are directed, and the static nature of modules makes any aliasing statically apparent. With units as values and potentially mutually dependent, however, aliasing creates various problems — including the possibility that mutually dependent units might export and re-export the same variable (so that it doesn’t exist anywhere). So, aliasing is just not allowed with a unit’s imports and exports.

that makes sense. thanks!

I think this could be solved by repeating the linking step until it reaches a fixed point, and then raising an error if there are missing links. If anyone wants to hack on the unit code…