set-value [Function]


Purpose

The set-value function replaces the current value of a given single-valued role on a given instance.

Syntax

set-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 single-valued relation, or the name of such a relation.

The value argument is the new value 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 name of the context, where 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 new value of role is returned. If it fails and no-error-p is set, then: (1) if the type of value conflicts with the range of role, the two values nil and :type-clash are returned, (2) if instance (or role) cannot be found, nil and :missing-instance (or :missing-role) are returned.

Examples

(defrelation r :characteristics :single-valued) 
(set-value 'Joe 'r 3) ==> 3 
(set-value 'Joe 'r '(3 4 5)) ==> (3 4 5) 
(set-value (fi Joe) (fr r) nil :context "CL-USER-THEORY") ==> NIL 
(set-value 'Joe 'r 'Mary) ==> |I|MARY 
(defrelation s :characteristics :single-valued :range Symbol) 
(set-value 'Joe 's 'Mary) ==> MARY 
(set-value 'Joe 's 3 :no-error-p t) ==> NIL :TYPE-CLASH

See Also

Last modified: Jul 1 1999