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: SRFI-17


Keith Wright <kwright@gis.net> writes:

> It can be troublesome to remember the name of the setter that goes
> with your favorite getter, both because setters are used less (some
> large programs _never_ use them), and because the naming conventions
> are haphazard by tradition and standard.

I think another powerful argument for a generalized `set!' (or
`setf!') is that it allows you to write useful macros like `push!',
`pop!' etc that use getters and setters to modify a certain location
(or whatever is accessed by the getter/setter).

For example, you could define (sorry, I'm not fluent with syntax-case)

    (define-macro (loc expr)
      `(lambda args
         (if (null? args) 
             ,expr
             (set! ,expr (car args)))))

    (define (loc-ref l)
      (l))

    (define (loc-set! l v)
      (l v))

and have an abstraction for something like lvalues.

- Marius

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