m4burns
2021-12-14 22:21:08

@m4burns has joined the channel


dan.hillier.anderson
2021-12-14 22:30:19

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))))


dan.hillier.anderson
2021-12-14 22:32:26

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


dan.hillier.anderson
2021-12-14 22:34:35

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


mflatt
2021-12-14 22:42:10

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.


dan.hillier.anderson
2021-12-14 22:42:59

that makes sense. thanks!


ryanc
2021-12-14 23:09:53

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…