[plt-scheme] Re: Swindle CLOS ?

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Mar 9 21:01:12 EST 2007

On Mar  9, Kyle Smith wrote:
> Eli Barzilay <eli at ...> writes:
> > I don't see any reason to do this: conceptually, `x' is a field of
> > Point, so a `ColoredPoint-x' doesn't make much sense to me.  But the
> > `Point-x' thing is in any case a generic function -- which means that
> > it does not "belong" to Point -- it just happens to have a method that
> > is qualified for Points.  So, you can have it called `get-x' and then
> > it's independent of any class name (there is an option that makes it
> > use `x' for a name, it's just that it's a bad name in this case).
> > (There is even a customization option that defines the accessor as a
> > plain function instead of a generic -- basically one that is doing the
> > actual accessing through (slot-ref foo 'x).)
> Thanks for your reply Eli,
> Don't confuse my wanting to emulate Meroonet with Swindle CLOS as an
> endorsement of how Meroonet does things,

No, I just said that I personally don't see any sense in doing that
(adding a `ColoredPoint-x' accessor in your example) which is why I
didn't do it at the time.  It only defines accessors that are
syntactically part of the definition -- for example:

  (defclass Point () x y :auto #t :print #t)
  (defclass ColoredPoint (Point) x y color :auto #t :print #t)

will give you a `ColoredPoint-x' that is independent from `Point-x'.
(The whole auto-accessor thing is my own thing, BTW, so there's no
CLOS tradition to follow there (IIRC, at least).)

> [...]
> I saw the other options for accessor names, but they seemed worse by
> far than the default, since you don't want name collisions between
> functions because you haven't qualified the name with the class
> name.

(I guessed you won't like it -- it can make less of the type
information be part of the name.  But it does make sense if your
accessors have good names.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.