🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #1

Re: new instance structure protocol

#1
From: Aaron Larson
Date: Thu, 29 Oct 1992 01:47
43 lines
2280 bytes
I'm afraid I don't get it.  How is a metaclass which doesn't want CLOS to
store information (i.e. no field allocated) supposed to determine what
*INSTANCE* the slot should be read/written to/from?

    (defun slot-value (object slot-name)
      (let* ((class (class-of object))
	     (eslotd  (find slot-name (class-slots class) :key #'slotd-name)))
	(destructuring-bind (field getter setter)
	    (cdr (assoc eslotd (slot-value class 'getters-n-setters)))
	  (funcall getter (and field (%%get-field object field))))))
			  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	
    (defun (setf slot-value) (new object slot-name)
      (let* ((class (class-of object))
	     (eslotd  (find slot-name (class-slots class) :key #'slotd-name)))
	(destructuring-bind (field getter setter)
	    (cdr (assoc eslotd (slot-value class 'getters-n-setters)))
	  (if field
	      (%%set-field object
			   field
			   (funcall setter (%%get-field object field) new))
	      (funcall setter nil new)))))
			      ^^^

Don't the "^^^" things indicate that getters and setters will always be
called with no indication of the object?  Shouldn't they be passed the
object itself?  For example, suppose that I wanted to store all slot
information for all objects in a single hash table (or database, or...).  The
getter essentially must do a gethash, with a key which is a combination of
the slot name, and some indication of the object, similarly for (setf
slot-value).  Shouldn't the above become:


    (defun slot-value (object slot-name)
      ...
	  (funcall getter (if field
	  		      (%%get-field object field)
			      object)))))

	
    (defun (setf slot-value) (new object slot-name)
      ...
	      (funcall setter object new)))))
Technical Details
Message-ID: <9210290147.AA08205@gendibal.src.honeywell.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!sol.ctr.columbia.edu!src.honeywell.com!mail-enters-news

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.clos
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!sol.ctr.columbia.edu!src.honeywell.com!mail-enters-news
From: alarson@src.honeywell.com (Aaron Larson)
Subject: Re: new instance structure protocol
To: comp.lang.clos
Message-ID: <9210290147.AA08205@gendibal.src.honeywell.com>
Posted-Date: Wed, 28 Oct 92 19: 47:35 CST
Sender: alarson@src.honeywell.com (Aaron Larson)
Organization: Honeywell Systems & Research Center
Date: Thu, 29 Oct 1992 01:47:35 GMT
Received-Date: Wed, 28 Oct 92 19: 47:36 CST
Lines: 43