guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: macro syntax


From: Aurelien Chanudet
Subject: Re: macro syntax
Date: Wed, 2 Nov 2005 11:03:49 +0100

Hi,
 
And thanks for your attention.
 
I'd like something in the following flavor :
 
(define alist (list (cons "f" 1) (cons "g" 2)))
 
(defmacro-public new-func (f str) some code here to retrieve x from the alist given str `(define (,f) ,x))

(new-func f "f")
(new-func g "g")
 
On 11/2/05, Ludovic Courtès <address@hidden> wrote:
Hi,

Aurelien Chanudet <address@hidden > writes:

> (define (find-x f) (cdr (assoc f alist)))

You might want to use `assoc-ref' instead of `find-x'.
 
Thanks for the tip !

> How can I rewrite the macro new-func to factor out find-x in the macro
> definition ?

I don't clearly understand what you mean.  Could you rephrase it?

Thanks,
Ludovic.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]