This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Some questions about GOOPS and CLOS in general
Mikael Djurfeldt <mdj@thalamus.nada.kth.se> writes:
> Also, the use of `slot-ref' easily gives unreadable code, compare:
> (set! (d o) (sqrt (+ (x o) (y o))))
> with
> (slot-set! o 'd (sqrt (+ (slot-ref o 'x) (slot-ref o 'y))))
> `slot-ref' doesn't give much extra useful information in the syntax,
> but it does decrease readability.
One alternative is:
(o 'x)
This assumes you view an object as a mapping from names to locations (slots).
Since this is object what an object *is* mathematically, this is not an
unreasonable syntax. You could use the same syntax for environment lookup,
access to componenrts of module (instances), and record fields. (You can also
go further and write (a i) instead of (vector-ref a i).)
(I am currently in Denmark, and probably wonøt be able to reply for a week.)
--
--Per Bothner
bothner@pacbell.net per@bothner.com http://www.bothner.com/~per/