add-value [Function]


Purpose

The add-value function adds a value to a given role on a given instance.

Syntax

add-value instance role value &key context no-error-p

Arguments

The instance argument is an instance or an instance identifier.

The role argument is a relation, or the name of a relation.

The value argument is a value to be added to the fillers of role. If value is a list, the list is interpreted as a single role filler. If value is a symbol, the value is coerced to an instance unless the the range of role indicates that it should be interpreted as a constant.

The context argument is the context, or the symbol or string that names the context, where the lookup of instance and role begins. This defaults to the current context.

If the no-error-p argument is t, then error messages are suppressed.

Value

If the update is successful, the newly added value is returned. If it fails and no-error-p is set, then: (1) if role is single-valued and already has a filler, the two values nil and :too-many-fillers are returned, (2) if the type of value conflicts with the range of role, nil and :type-clash are returned, (3) if instance (or role) cannot be found, nil and :missing-instance (or :missing-role) are returned.

Examples

(defrelation rr)  
(add-value 'Joe 'rr 'Fred) ==> |I|FRED 
(add-value (fi Joe) (fr rr) (fi Sue) :context "CL-USER-THEORY") ==> |I|SUE 
(add-value 'Joe 'rr '(3 4 5)) ==> (3 4 5) 
(get-values 'Joe 'rr) ==> (|I|FRED |I|SUE (3 4 5)) 
(defrelation ss :range Symbol) 
(add-value 'Joe 'ss 'Fred) ==> FRED 
(defrelation r :characteristics :single-valued) 
(add-value 'Joe 'r 'Fred) ==> |I|FRED 
(add-value 'Joe 'r 'Sue :no-error-p t) ==> NIL :TOO-MANY-FILLERS 
(get-values 'Joe 'r) ==> (|I|FRED)

See Also

Last modified: Jun 1 1995