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


> Can you explain how you would implement (setter ...) ? I can't quite
> see how it works.

Well, each procedure optionally has a setter attribute associated with it,
and (setter PROC) retrieves the setter attribute.  If there is no setter,
an eror is signalled.

The question then is how does one get the setter attribute?  Well, there
can be many implementations.  In Kawa, procedures are instances of
the Procedure class, and settable procedures implement the HasSetter
interface.  That means means the procededure (actually its class)
implements the getSetter method.  (It is actually a bit more
complicated than that, mainly for efficiency reasons.)

So how does a procedure get to implement the getSetter method?
Currently, it has to b wired in - i.e. only certain standard
procedures provide getSetter.  But I do intend for user procedures
that define a setter attributes (Scheme syntax for this not decided)
to cause a getSetter method compiled for them.  And is is easy to
create a procedure that takes a procedure and a setter procedure
and returns a procedure with an associated setter.

I think it is use to have some conecpt of "augmented functions"
- i.e functions with associated attributes.  The interesting 
question is what kind of data structure to use - whether to
optimize for a general data-structure with user-definable
attributes (e.g. a hash-table), or to optimize for standard
system builtin-attributes (i.e. slot with offsets) or a
combination.

For how implement this in Guile?  I leave that to Guile
implementors.  One reason I preferred to start from scratch
with Kawa is that having an object-oriented implementation
core is easier to extend.

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner