Re: #!quote

Matthias Radestock <[email protected]>
Newsgroups gmane.comp.java.sisc.devel
Message-ID <[email protected]>
Turadg Aleahmad wrote:

> Matthias Radestock wrote:
> 
>> Scott may know a way of fixing your problem. However, it occurred to 
>> me that what you'd really want is to redefine DEFINE so that you can 
>> get hold of the *original* (pre macro expansion) body.
> 
> 
> 
> Yes! That's exactly what I want.
> 
> I don't think I understand how to use this snippet:
> 
>> (let-syntax ([old-define (syntax-rules ()
>>                            [(_ . rest) (define . rest)])])
>>   (define-syntax define
>>     (syntax-rules (lambda)
>>       [(_ name (lambda formals . body))
>>        (old-define name (let ([p (lambda formals . body)])
>>                           (set-procedure-property! p 'definition
>>                                                    '(lambda formals . 
>> body))
>>                           p))]
>>       [(_ (name . formals) . body)
>>        (define name (lambda formals . body))]
>>       [(_ . rest) (old-define . rest)])))
> 
> 
> 
> The parens are balanced in the above.
> 
>>     (define (foo x) x)))
> 
> 
> 
> But then you give this line which has an extra two close-parens.  Where 
> is is supposed to fit? 

oops. mailed the wrong snipped. Try this:

(import procedure-properties)
(let-syntax ([old-define (syntax-rules ()
                            [(_ . rest) (define . rest)])])
   (letrec-syntax
       ([define (syntax-rules (lambda)
                  [(_ name (lambda formals . body))
                   (old-define name (let ([p (lambda formals . body)])
                                      (set-procedure-property!
                                       p 'definition
                                       '(lambda formals . body))
                                      p))]
                  [(_ (name . formals) . body)
                   (define name (lambda formals . body))]
                  [(_ . rest) (old-define . rest)])))
     (define (foo x) x)))
(procedure-property foo 'definition)


Matthias.




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.