Hi all,<br><br>I timidly require your help on a simple macro I've been trying to do for some time now.<br><br>I usually prefer to do things myself, but I'm stuck.<br><br>Here's the thing :<br>I have an identifier and I want to generate an identifier based on it but with a different name.<br>
(in fact I have lots of identifiers)<br><br>for example :<br>(define-my-id trout) <br>would generate the macro identifier my-id-trout that expands to, say, (display "trout").<br>My concern is about using in the program an identifier that is not defined explicitly in the program file.<br>
This should be possible though, since this is partly what define-struct does, I suppose.<br><br><br>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):<br>
(define (define-my-id id)<br> (eval `(define ,(string->symbol (string-append "my-id-" (symbol->string id))) <br> (lambda () (display ,(symbol->string id))))))<br><br>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...<br>
<br>Also, where can I find some simple macro samples, other than in the guide ?<br><br>Thanks a lot,<br>Laurent<br><br><br>