[plt-scheme] let-values/invoke-unit?
--- "Paulo J. Matos" <pocm at soton.ac.uk> wrote:
> [...]
>
> 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?
You can use 'define-values/invoke-unit' as an internal definition,
like this:
(let ()
(define-values/invoke-unit my-unit@ (import sig1^) (export sig2^))
do-some-things)
In fact, you can write 'let-values/invoke-unit' as a macro yourself,
in terms of internal 'define-values/invoke-unit'. Here's how it would
look, using a syntax I just made up:
(define-syntax let-values/invoke-unit
(syntax-rules ()
[(let-values/invoke-unit ((sig ...) unit-expr import-sig ...) .
body)
(let ()
(define-values/invoke-unit unit-expr
(import import-sig ...)
(export sig ...))
(begin . body))]))
Hope that helps!
Ryan
>
> Cheers,
> --
> Paulo Jorge Matos - pocm at soton.ac.uk
> http://www.personal.soton.ac.uk/pocm
> PhD Student @ ECS
> University of Southampton, UK
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
____________________________________________________________________________________
The fish are biting.
Get more visitors on your site using Yahoo! Search Marketing.
http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php