The operations in this section provide read and write access to the values of slots. Many of these operations are loosely defined in that we define neither their return values, nor their behavior under errorish conditions. For example, we do not define the behavior of remove-slot-value if the value specified for removal is not actually a value of the slot. In both cases, the ambiguity is deliberate to both simplify and speed up GFP implementations: given that some FRSs will have behavior different from whatever choice we make, there will be a cost to coercing their behaviors within the GFP layer. Therefore, users of these operations should not depend on any particular return values. We urge implementors of these operations to use idempotent semantics, for example, to not have a function such as remove-slot-value signal an error if the specified value is not present in the slot.
Several of these functions must test whether a given slot value is equal to some designated object. As discussed in Chapter 4, the function used to test equality is specified as a behavior for a class of frame systems. The slot manipulation functions that employ equality testing have a keyword argument test that defaults to the class-specific equality testing function for the frame system in question, but that can be set as desired for a given function call.
get-slot-values frame slot &key kb local-only-p (slot-type :auto) (number-of-values :all) kb-local-only-p
This function returns the entire set of values of own slot slot within frame, in no guaranteed order. It always returns a list of slot values. If the specified slot has no values, a null list is returned.
local-only-p is a filter on the slot values returned. If this argument is non-NIL, then only those values that have been asserted explicitly for this slot are returned. Values that are not local are those that are inferred (e.g., by inheritance or rule firing) or otherwise computed (e.g., by method or demon invocation). In most FRSs, local values can be determined more quickly.
get-slot-value frame slot &key kb local-only-p (slot-type :auto) kb-local-only-p
This function returns a single arbitrary member of the set of values of the own slot slot. It useful for single valued slots.
get-frame-with-slot-value frame slot value &key kb local-only-p (slot-type :auto) kb-local-only-p
When called with a putative value of slot in frame, returns the frame in which the slot value was asserted locally, or nil if the system is unable to find the owner of the slot value. No commitment is made about the means by which the slot value was associated with the frame when local-only-p is nil. Any given FRS might use simple class/subclass inheritance to derive the slot value, or some more sophisticated inference. The purpose of this function is to allow user interfaces to take users from a value displayed as a slot value on a particular frame to the place that asserted the value. Many FRSs will not be able to implement this operation, so it is important for client programs not to rely on getting a non-nil result. If the value argument is not in fact a value of the slot in question then the result will be nil.
follow-slot-chain frame slot-chain &key kb union-multiple-values kb-local-only-p
This function allows one to traverse a chain of slot references, gathering own slot values. For example, imagine that we wish to determine the sisters of the father of the mother of John. The following two calls accomplish this goal:
(follow-slot-chain 'john '(mother father sisters)) (get-slot-values) (get-slot-values (get-slot-values 'john 'mother) 'father) 'sisters)
This function is complicated by the fact that slots can have multiple values. For example, imagine that John has two mothers--adopted and biological. If union-multiple-values is nil we signal an error; if T, then the slot chain becomes a tree, and we return the union of all values found at the leaves of the tree.
put-slot-values frame slot values &key kb (slot-type :auto) kb-local-only-p
This function sets the value of own slot slot in frame to be values, which is assumed to be a set. The order of the elements of values will not necessarily be maintained by the FRS. This function may signal constraint violation conditions (see Section 5.2).
put-slot-value frame slot value &key kb (slot-type :auto) kb-local-only-p
This sets the value of slot in frame to be a set consisting of a single element: value. This function may signal constraint violation conditions (see Section 5.2).
add-slot-value frame slot value &key kb test (slot-type :auto) add-after kb-local-only-p
value is added to the set of values of slot. If the collection-type of slot is :set, then value is added only if slot does not already contain value. add-after, if supplied, should be an integer between 0 and the number of existing values, inclusive. If the collection-type of slot is :list, value is added immediately after the value indexed by add-after. For example, if add-after is 1, the new value will be added between the first and second old values. If add-after is not supplied, and the collection-type of slot is :list, then value is added to the front of the list. This function may signal constraint violation conditions (see Section 5.2).
replace-slot-value frame slot old-value new-value &key kb test (slot-type :auto) (index :all) kb-local-only-p.
If old-value is currently a member of the set of local values of slot, then old-value is replaced by new-value in slot. If index is :all then all occurrences of old-value will be replaced. Otherwise, index should be an integer index into the values list, and only the value at that position, if it matches old-value, will be replaced (the first value of the slot is index 1). This function may signal constraint violation conditions (see Section 5.2).
remove-slot-value kb frame slot value &key kb test (slot-type :auto) (index :all) kb-local-only-p
If value is currently a member of the set of local values of slot, then value is removed from the values of slot. If index is :all then all occurrences of value will be removed. Otherwise, index should be an integer index into the values list, and only the value at that position, if it matches value, will be removed (the first value of the slot is index 1).
remove-local-slot-values frame slot &key kb (slot-type :auto) kb-local-only-p
Removes all local values in slot of frame.
member-slot-value-p frame slot value &key kb test (slot-type :auto) kb-local-only-p
Returns non-nil iff value is a value in slot of frame, as determined by the predicate test. The predicate test defaults to the default test function for the current frame system.
slot-has-value-p frame slot &key kb (slot-type :auto) kb-local-only-p
Returns true iff own slot slot of frame has some value, local or nonlocal.
slot-p frame thing &key kb slot-type kb-local-only-p
Returns true iff thing is a valid slot in frame.
create-slot name attach-to &key kb create-p slot-type error-p kb-local-only-p
Creates a slot name in the frame(s) specified by attach-to, which can be either a single frame or a list of frames. If create-p is t (the default), a slot frame object is created for the new slot.
delete-slot slot &key kb delete-values-p kb-local-only-p
Deletes the slot frame. If delete-values-p is t (the default), all values for the slot in all frames are deleted.
rename-slot slot new-name &key kb kb-local-only-p
mapcar-slot-values frame slot function &key kb (local-only-p nil) (slot-type :auto) (number-of-values :all) (kb-local-only-p t)
Map function over every value in the specified slot.
mapc-slot-values frame slot function &key kb (local-only-p nil) (slot-type :auto) (number-of-values :all) (kb-local-only-p t)
Map function over every value in the specified slot.
do-slot-values (var frame slot &key kb (local-only-p nil) (slot-type :auto) (number-of-values :all) kb-local-only-p) &body body Macro
Repeatedly executes body; on each repetition, var is bound to a different value in the specified slot.