[racket-dev] behavior of 'local-transformer-expand' changed

From: Tobias Hammer (tobias.hammer at dlr.de)
Date: Thu Aug 1 09:35:38 EDT 2013

Here is a strip down example of a case that worked before and gave an  
error with the new version.
I was only interested in the information if the argument to mac could be  
expanded to something bound or not. So the quick solution here was to wrap  
the provide in begin and expand it in 'top-level.


PS: The whole local-expand construct is only needed in my case to work  
around the unfortunate behavior that racket lacks source locations in  
error message for transformer phase. It would really, really simplify  
debugging if that could be changed.

;; --- example

#lang racket
(require (for-syntax racket))

(define-syntax (mac stx)
   (syntax-case stx ()
     [(_ id val)
        (define e (local-transformer-expand #'val
                                            ;; 'module worked before
        #`(begin-for-syntax #,e))]))

   (define C 'C)

   (define-syntax (B stx)
     (syntax-case stx ()
        #'(provide C)])))

(mac id (B))

On Thu, 01 Aug 2013 14:16:14 +0200, Matthew Flatt <mflatt at cs.utah.edu>  

> I removed those options because the implementation did not look
> sensible for those cases.
> Implementation aside, using 'module-begin doesn't make sense to me. A
> form in the place of `#%module-begin' is always expanded at phase-level
> 0, so there isn't really.
> I'm less certain about 'module. It may make sense to use 'module and
> get the same effect as wrapping the form with `begin-for-syntax',
> expanding with `local-expand', and removing the expansion again. Do you
> have an example where you use 'module?
> At Thu, 1 Aug 2013 10:12:16 +0200, Tobias Hammer wrote:
>> Hi,
>> Commit e51ac9cc [1] from about a month ago changed the allowed values  
>> for
>> local-transformer-expands context-v argument. It now refuses 'module and
>> 'module-begin. Previously i could simply pass the result from
>> syntax-local-context.
>> I am not sure what i should pass now and what implications the change  
>> has.
>> Any hints appreciated.
>> Tobias
>> [1] http://git.racket-lang.org/plt/commitdiff/e51ac9cc
>> _________________________
>>   Racket Developers list:
>>   http://lists.racket-lang.org/dev

Tobias Hammer
DLR / Robotics and Mechatronics Center (RMC)
Muenchner Str. 20, D-82234 Wessling
Tel.: 08153/28-1487
Mail: tobias.hammer at dlr.de

Posted on the dev mailing list.