This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Syntatic sugar and identifier permissivity


Ole Myren Rohne <ole.rohne@cern.ch> writes:

> 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.

You want

    (inc! (accessor (some-expensive-operation)))

to expand into something like

    (let ((arg1 (some-expensive-operation)))
      (set! (accessor arg1) (+ (accessor arg1) 1)))

- Marius

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]