🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #297

Re: SETF methods

#297
From: john
Date: Thu, 12 Nov 1992 17:21
41 lines
2502 bytes
Hallvard Tr{tteberg (haltraet%monsun.si.no@uunet.uu.net) writes:

  ... the set of methods of a class should preserve a set of
  invariants related to the class. I.e. the object state before and
  after a (official or exported) method is run should satisfy a set of
  constraints, which of course could be violated while running the
  method.
  With CLOS the methods don't belong to a class but I think the view
  could be adopted, especially in the non-multi method case.

I agree that this is a useful way to look at things.  Some languages,
notably Eiffel, give you ways to make this explicit.  The addition of
such mechanisms to Dylan is also being discussed.  It's nice to be
able to turn the constraint-checking machinery off, especially
selectively.  I don't know if your framework would easily support that
sort of thing.

  My question is whether it's best to generate setf-around-methods to
  take care of such a constraint, or should I make another layer of
  methods, e.g. SET-NODE-OUT-EDGES and SET-EDGE-FROM-NODE ...
  A problem I see, is that the user of the setf-method perhaps expects
  the implementation to have low computational complexity ...

I think SETF methods are perfectly appropriate for this.  The user of
a generic function should have no expectations about its
implementation, unless you state some.  Even if all of the methods are
slot-accessors, there still may be many more than one of them.  I
often write SETF generic functions in which NO methods correspond to
slot-access.  I also use :AROUND, etc., methods on SETFs in which the
primary methods are slot-accessors, often to do exactly the sort of
thing you discuss.

I feel very strongly that one of the strengths of CLOS is that slot
accessors are just methods (a Lisp implementation's special treatment
of them notwithstanding).  Any user who makes such assumptions about
them just doesn't get it.  Anyway, such a user would probably make the
same assumptions about functions named SET-NODE-OUT-EDGES and
SET-EDGE-FROM-NODE.

John Burger
john@mitre.org
Technical Details
Message-ID: <9211121721.AA06525@thelonius.mitre.org>
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!linus.mitre.org!john

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.clos
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!linus.mitre.org!john
From: john@linus.mitre.org
Subject: Re: SETF methods
Message-ID: <9211121721.AA06525@thelonius.mitre.org>
Sender: daemon@cis.ohio-state.edu
Organization: The Ohio State University Department of Computer and Information Science
Date: Thu, 12 Nov 1992 17:21:05 GMT
Lines: 42