This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Syntatic sugar and identifier permissivity
Marius Vollmer writes:
> > (defmacro inc! (place . val)
> > `(set! ,place (+ ,place ,(if (null? val) 1 (car val)))))
>
> I think for production code, you should be careful to evaluate the
> subforms of `place' only once.
I am not sure I understand the problem, maybe because I really don't
understand how set! and macros works. Anyway, this is what I believe
should happen:
(inc! symbol)
-> (set! symbol (+ symbol 1))
(inc! (procedure-with-setter object))
-> (set! (procedure-with-setter object)
(+ (procedure-with-setter object) 1))
-> ((setter procedure-with-setter)
object
(+ (procedure-with-setter object) 1))
In each case it is up to set! to evaluate `place' as needed. It seems
to me that symbol and (procedure-with-setter object) are the only
options for the first argument to set! and I don't think it make sense
to have inc!/dec! go further.
Regards,
Ole