This is the mail archive of the guile@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: setf.scm


Maciej Stachowiak <mstachow@MIT.EDU> writes:

> I think a purely dynamic one would be more in the spirit of Scheme.

I tend to agree.

In STk, (setter car) is treated as a variable name in some places.
But since, you can't do things like

  (let (((setter car) set-car!)) ...)

and since the syntax

  (define (setter x) ...)

becomes very ambiguous, the idea is a bit unschemey.

But, what I can't accept with the dynamic setf! is that it would be
difficult to compile to efficient code.

Note that the use of setf! is an elementary operation in Goops (the
Guile object system).  It should be efficient.  It is unacceptable to
go looking into property lists at each use of a slot setter.

The reason why I added setf! to guile-core was that the STk slot
option #:accessor <name> creates the accessors <name> and (setter
<name) for the slot.

Now I'm thinking of letting #:accessor <name> create the accessors
<name> and set-<name>! instead.

Example:

  (define-class <c> ()
    ((x #:accessor x)))

  (define o (make <c>))

  (set-x! o 1)
  (x o) --> 1

That is reasonably schemey and is easier to compile to efficient code.

If I make this change, I want to remove setf! from guile-core.  It can
be supplied as a separate package.

Opinions?

/mdj