[plt-scheme] #'(require help)

From: Laurent (laurent.orseau at gmail.com)
Date: Sat Sep 26 14:34:20 EDT 2009

Hi all,

I timidly require your help on a simple macro I've been trying to do for
some time now.

I usually prefer to do things myself, but I'm stuck.

Here's the thing :
I have an identifier and I want to generate an identifier based on it but
with a different name.
(in fact I have lots of identifiers)

for example :
(define-my-id trout)
would generate the macro identifier my-id-trout that expands to, say,
(display "trout").
My concern is about using in the program an identifier that is not defined
explicitly in the program file.
This should be possible though, since this is partly what define-struct
does, I suppose.


With eval and quasi-quoting I can easily generate an approximation with a
lambda'd form but Scheme won't let me use identifiers that are not
explicitly defined (it works in the REPL though):
(define (define-my-id id)
  (eval `(define ,(string->symbol (string-append "my-id-" (symbol->string
id)))
        (lambda () (display ,(symbol->string id))))))

I also know that syntax-id-rules can generate expanding identifiers, but I
can't use string-append et al in macros to generate a new id...

Also, where can I find some simple macro samples, other than in the guide ?

Thanks a lot,
Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090926/9325a17a/attachment.html>

Posted on the users mailing list.