[plt-scheme] let-values/invoke-unit?

From: Paulo J. Matos (pocm at soton.ac.uk)
Date: Thu Mar 8 17:34:08 EST 2007

Hello all,

My problem goes as follows: I'm working around a plugin system (using
units) which defines a printer (one argument function), which receives
a value and returns the string which should be displayed for the

I keep a simple symbol-table like an hash-table where the key is a
symbol and the value is the lambda corresponding to the printer. So,
if in the REPL I get (load-printer 'blabla) I know I have to load the
file blabla.zo which contains a compiled unit which defines the
printer for the 'blabla value. So I might have :
(load-printer 'foo)
(load-printer 'bar)

and in foo.zo I have a unit which defines
(lambda (x)
     (format "this is a foo ~a~n" x))
and in bar.zo I have a unit which defines
(lambda (x)
     (format "this is a bar ~a~n" x))

Now, I have two options. Either I import in to the units a register
function which registers the printer and the unit is responsible for
installing the printer, or I export from the unit the printer function
and I install in my hash-table.
The latter seems cleaner since the unit should not need to register
the function, it's only job is to provide a printer. However, the
latter requires (I think)  a let-values/invoke-unit, since it would
seem pretty nice to have. It seems there is no such function and
define-values/invoke-unit does suit my need because I don't want to
the define the export values in the top-level, I want to capture them
in a variable and then register them.

Any suggestions? I guess it is possible to do let-values/invoke-unit
(at least emulate its behaviour). I guess I might do this by defining
a compound unit from the plugin and a register unit which registers
the imports from the plugin but I would like some comments on this. Is
this the way to go?

Paulo Jorge Matos - pocm at soton.ac.uk
PhD Student @ ECS
University of Southampton, UK

Posted on the users mailing list.