next up previous contents index
Next: Operations on Slot Values Up: Slot-Access Functions Previous: Slot-Access Functions

Slot Enumeration

Slots are mappings from frames to values (more precisely, from frames to facets). The Generic Frame Protocol distinguishes two types of slots, instance and template slots. Own slots are like binary relations that map a frame to some values. Template slots are like rules or schemata that characterize a slot for all instances of a class. The values of a slot are unordered; to preserve order an application should maintain a list as the single value for the slot.

See Section 2.2 for background information on slots.

In these functions, slots are identified by Lisp symbols, and frames are identified by Lisp symbols or frame objects returned by the FRS.

As mentioned above, it is necessary to be able to distinguish between intended operations on a slot of a given name if a frame contains both an own and a template slot of the same name. Numerous GFP functions take a slot-type keyword argument. This argument may take on one of three values; {:own, :template, :auto}. If the value of this argument is :own, then the function call refers to an own slot in the specified frame. If the value is :template then the call refers to a template slot. If the value is :auto (the default) then the call is taken refer to be an own slot in an instance and either an own slot or a template slot in a class depending on which is present as long as not both are present in the class. If both an own slot and a template slot of the specified name are present in the class then the function refers to the own slot. Thus if the user really means to refer to a template slot in a particular class then a value of :template should be used. Some FRSs do not allow frames to have both own and template slots of the same name, in which case :auto is always sufficient, though the use of the correct :own or :template keyword will be more portable.

It is worth noting that a call such as (get-slot-value 'bill 'age :slot-type :own :local-only-p nil) may result in a reference to a template slot even though the slot-type specified is :own. This is because of the value of the local-only-p argument, which causes slot value inheritance possibly to inherit a value for the slot from the classes of which it is an instance as if it were an own slot in frame.

get-frame-slots  frame &key kb slot-filter slot-type kb-local-only-p

Returns the list of instance or template slots that are associated with frame. Slot-type must be :template, :own, or :all and defaults to :all.

Slot-filter is an atomic keyword or a predicate that further restricts the subset of the slots defined for frame that are returned, as follows:

get-frame-facets  frame &key kb slot-type slot-filter kb-local-only-p

Returns the list of facets on instance or template slots that are associated with frame. Slot-type must be :template, :own, or :all and defaults to :all.

Slot-filter is an atomic keyword or a predicate that further restricts the subset of the slots defined for frame that are returned, as follows:

put-instance-types  instance new-types &key kb kb-local-only-p

Changes instance to be an instance of all the classes listed in new-types.

get-own-slots  frame &key kb which-slots

mapcar-frame-slots  frame function &kb kb (slot-filter :all) (slot-type :auto) kb-local-only-p

Apply function over all slots in a frame. The function should take a single argument, the symbol naming the slot. Both own and template slots are included, and no filters are applied.

mapc-frame-slots  frame function &key kb (slot-filter :all) (slot-type :auto) kb-local-only-p

Apply function over all slots in a frame. The function should take a single argument, the symbol naming the slot. Both own and template slots are included, and no filters are applied.

do-frame-slots  (var frame &key kb (slot-filter :all) (slot-type :auto) kb-local-only-p) &body body Macro

Repeatedly executes body; on each repetition, var is bound to a different slot (a symbol) in the specified frame.

slot-type  frame slot-name &key kb kb-local-only-p

Returns a value in the set {:own, :template, nil}. If the slot named by slot-name is an own slot in frame, then :own is returned. If frame has a template slot of the supplied name, but no own slot of that name then :template is returned. If there is both an own and a template slot named slot-name in frame, then :own is returned. This means that (slot-type frame slot-name) as the value to the slot-type keyword argument of any GFP function will result in the equivalent semantics to those provided by the :auto keyword. If no slot named slot-name is identifiable in frame then nil is returned.

get-slot-type  frame slot &key kb


next up previous contents index
Next: Operations on Slot Values Up: Slot-Access Functions Previous: Slot-Access Functions

  • Peter Karp