[plt-scheme] define-values/invoke-unit in an internal definition context

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Oct 9 09:03:54 EDT 2008

Looks like a macro-expander bug to me. A few weeks ago, I adjusted the
way that identifier bindings are determined in internal-definition
contexts, and that change appears to be interacting badly with the
`unit' macros in this case. I'll have to investigate more.

Matthew

At Thu, 9 Oct 2008 08:08:24 +0100, "Noel Welsh" wrote:
> I'm trying to abstract over both macros and normal values, but having
> a problem that define-values/invoke-unit doesn't seem to work in a
> local definition context.  A simple example is below.  Reading the
> code is perhaps easier than explaining in words what I'm doing, so I
> won't go into detail here.  Can anyone tell me how to get it working?
> 
> Thanks,
> Noel
> 
> 
> #lang scheme/base
> 
> (require (for-syntax scheme/base)
>          scheme/unit
>          (planet schematics/schemeunit:3))
> 
> (define-signature sig^ (a b c))
> 
> (define unit@
>   (unit
>     (import)
>     (export sig^)
> 
>     (define a 0)
>     (define b 1)
>     (define c 2)))
> 
> (define-syntax macro1
>   (syntax-rules ()
>     [(_) (display "hello")]))
> 
> (define-syntax macro2
>   (syntax-rules ()
>     [(_) (display "o hai")]))
> 
> ;; Here we abstract over macros and the unit
> (define-syntax use-unit@
>   (syntax-rules ()
>     [(_ macro)
>      ((lambda (unit)
>         (define-values/invoke-unit unit (import) (export sig^))
>         (macro) (printf " ~a ~a ~a\n" a b c)))]))
> 
> '((use-unit@ macro1) unit@)
> ((use-unit@ macro2) unit@)
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.