🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Aaron Larson Thu, 29 Oct 1992 01:47
Re: new instance structure protocol
#1
Author: 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)))))
Re: new instance structure protocol
#10
Author: Gregor Kiczales
Date: Thu, 29 Oct 1992 20:00
27 lines
1921 bytes
In article <9210290147.AA08205@gendibal.src.honeywell.com> alarson@src.honeywell.com (Aaron Larson) writes:

   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:

You are correct that, in the prototocol I proposed, the getters and
setters do not receive the object.  This means that if the getters and
setters want an object id of some sort, they need to ask for that to be
stored in a field of the object.

One could change the protocol so that getters and setters received the
object.  If we were going to do that, I would suggest adding an
aditional argument, rather than overloading an existing argument.

I am working on an implementation of a very small CLOS, with a MOP, that
has this protocol.  Together with it are a bunch of examples of how to
use it.  (One neat thing about it is that it is all in Scheme.)  The
reflection and meta-level architectures workshop is next week, so I'll
probably send it out the week of the 9th.

Gregor
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads