[plt-scheme] On hygiene and trust

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Thu Jul 9 14:36:11 EDT 2009

Joe Marshall wrote:
> On Wed, Jul 8, 2009 at 5:41 PM, Abdulaziz Ghuloum<aghuloum at gmail.com> wrote:
>> On Jul 8, 2009, at 6:04 PM, Joe Marshall wrote:
>>
>>> On Wed, Jul 8, 2009 at 7:31 AM, Abdulaziz Ghuloum<aghuloum at gmail.com>
>>> wrote:
>>>> I don't agree.  Show me a painful simple use.  Pick any simple
>>>> macro you want: let, let*, or, and, cond, case, or any other
>>>> macro of your choice to show the pain.
>>> This came up the other day.  Transform something like this:
>>>
>>> (define-event foo bar (arg1 arg2 ...)
>>>   (form1)
>>>   (form2 ...) etc.)
>>>
>>> into something like this:
>>>
>>> (define (foo$bar arg1 arg2 ...)
>>>   (form1)
>>>   (form2 ...) etc.)
>> I don't see the pain caused by "syntax-case", and maybe I don't
>> understand the problem you're having.  Can you please write your
>> macro in syntax-case because my attempt below probably does not
>> do what you had in mind.
>>
>> (define-syntax define-event
>>  (lambda (stx)
>>    (define (concat x y) --- fill in the blank ---)
>>    (syntax-case stx ()
>>      [(_ foo bar (arg1 arg2 ...)
>>          (form1)
>>          (form2 ...) etc.)
>>       #`(define (#,(concat #'foo #'bar) arg1 arg2 ...)
>>           (form1)
>>           (form2 ...) etc.)])))
> 
> (define-syntax define-event
>  (lambda (stx)
>    (define (concat . x)
>     (string->symbol (apply string-append (map symbol->string x))))
>    (syntax-case stx ()
>      [(_ foo bar arguments form1 . body)
>       #`(define (#,(concat #'foo '$ #'bar) . arguments)
>           form1 . body)])))
> 
> (define-event foo bar (x y) (list x y))
> collects\scheme\private\map.ss:22:17: symbol->string: expects argument
> of type <symbol>; given #<syntax:3:16>
> 
> This is what usually happens when I try to use syntax-case.  I end up getting
> syntax objects where I want symbols, or symbols where I want syntax objects,
> or syntax object closed in the wrong scope.  Then I end up trying permutations
> of sharps, backticks, commas, and quotes until it eventually works.
...
> I want something else.  I'm not sure what, though.

Perhaps it is this?

    * Wrapped = Unwrapped (r6rs optional):

        A wrapped syntax object is the same as an unwrapped syntax
        object, and can be directly manipulated using car, cdr, ...
        without syntax-case deconstruction.

    http://www.het.brown.edu/people/andre/macros/

David



Posted on the users mailing list.