[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Explain 1this0
- To: slug%ai.sri.com@riverside.scrc.symbolics.com
- Subject: Explain 1this0
- From: Shepard@MCKENZIE.S&C.Dialnet.Symbolics.COM (Tom Shepard)
- Date: Fri, 30 Nov 1990 12:28:00 -0500
- Character-type-mappings: (1 0 (NIL 0) (NIL :ITALIC NIL) "CPTFONTI") (2 0 (NIL 0) (NIL :BOLD NIL) "CPTFONTCB")
- Fonts: CPTFONT, CPTFONTI, CPTFONTCB
The flavor 1Standin0 in the following example was created to test an idea
about automatic, transparent, demand caching. In actual use, a standin
would either locate the instantiated object for which it stands, or
instantiate it from data from some external source and connect it with
its instatiated neighbors. The idea is for the standin object to be
transparent, passing all messages on to the object it stands for.
However, it was late when the example was created, and we didn't want to
go to all the trouble of establishing object identity. The following
abomination resulted. Have fun!
- Tom Shepard and Bill Gooch
1) Compile the code below.
2) Evaluate FU1 in a listener.
3) Point to it. Observe the Mouse L and Mouse M documentation.
4) Move off it, then back on, and observe the mouse doc again.
5) Click on it. Observe the result.
6) Evaluate FU2 (and abort after a few lines). Being a circular list of
one object, you would expect the elements to all be the same.
7) Type "(eq ", then click on two different elements of the list. Type ")".
Observe the result.
P.S. Unfortunately, there is no simple translation of this to CLOS.
Because of multiple-argument dispatching, it doesn't make sense to blame
a particular argument's class for not implmenting a method. Because of
this, the :unclaimed-message protocol can't exist in CLOS.
;;; -*- Syntax: Common-Lisp; Package: COMMON-LISP-USER; Base: 10; Mode: LISP -*-
2;;; ********************************************************************************
0(defflavor 2Fooie 0((x 0)) () :initable-instance-variables)
(defmethod 2(sys:print-self Fooie)0 (Stream Print-Depth Slashify-P)
(ignore Print-Depth Slashify-P)
(princ X Stream))
2;;; ********************************************************************************
0(defflavor 2Standin 0()
()
:no-vanilla-flavor)
(defparameter 2N 00)
(defmethod 2(:unclaimed-message Standin)0 (&rest args)
(let ((obj (make-instance 'fooie :x (incf n))))
(values (apply obj args)
obj)))
;;; This was not required in 8.0, but is in 8.0.1. I think it has something
;;; to do with integration with CLOS, but I'm not sure. Anybody have any
;;; ideas? (In 8.0, sys:print-self is passed on by :unclaimed-message, but
;;; that doesn't work in 8.0.1.)
;;;
(defmethod 2(sys:print-self Standin)0 (Stream Print-depth Slashify-P)
(sys:print-self (make-instance 'Fooie :X (incf N))
Stream Print-Depth Slashify-P))
2;;; ********************************************************************************
0(defparameter 2FU1
0 (make-instance 'Standin))
(defparameter 2FU2
0 (circular-list (make-instance 'Standin)))