Testing the waters.

Kelly Murray kem@Franz.COM
Sun, 11 May 1997 22:19:27 -0700

> >AllegroStore and "KellyStore" (my secret internal code name for my version)
> >does not have a *root* object, like Objectstore does.
> >We have inverse functions, that take slot values and return the
> >one or many CLOS instances that have the given value for the slot

> Can you tell us more about this slot value and inverse function stuff?

An inverse function does the inverse of an slot accessor function.
Below is my webserver source for the class definition of a webpage.

(class <webpage> (<webpage-access-control>)
   (name :initarg :name
	 :unique t
	 :accessor webpage-name
	 :inverse webpage-from-name)  ;;; <== inverse function

;; make a persistent webpage
(make-instance '<webpage>' :name "demo") ==> #<webpage 1234>

;; takes a webpage, returns name slot
(webpage-name #<webpage 1234>) => "demo"

;; takes a slot value, returns the webpage with that value for the name slot
(webpage-from-name "demo") => #<webpage 1234>

Inverses are like high-level "content addressable memory".
You give the contents of the memory, it tells you the location of
those contents.  It makes finding things fast and efficient.
No root object is needed to traverse to find things, you find things
by asking for them by what values they contain.
This is implemented by having a btree or hashtable that maintains
the inverse relation.  Notice that if the slot-value is changed, the
inverse table must also be updated.  And if the instance is deleted too.

Here is our filesystem

(class <file> ()
   (name :initarg :name
	 :unique t
	 :accessor filename
	 :inverse openfile)  ;;; <== inverse function
   (contents :accessor filecontents)

(make-instance '<file>' :name "/etc/passwd") => #<file 4321>

(filename #<file 4321>) => "/etc/passwd"

(openfile "/etc/passwd") => #<file 4321>