next up previous

11.5 DERIVING A DEFAULT VALUE FROM CONSTRAINTS

Default values for deftemplate and instance slots are automatically derived from the constraints for the slots if an explicit default value is not specified. The following rules are used (in order) to determine the default value for a slot with an unspecified default value.

1) The default type for the slot is chosen from the list of allowed types for the slot in the following order of precedence: SYMBOL, STRING, INTEGER, FLOAT, INSTANCENAME, INSTANCEADDRESS, FACTADDRESS, EXTERNALADDRESS.

2) If the default type has an allowed constant restriction specified (such as the allowed-integers attribute for the INTEGER type), then the first value specified in the allowed constant attribute is chosen as the default value.

3) If the default value was not specified by step 2 and the default type is INTEGER or FLOAT and the range attribute is specified, then the minimum range value is used as the default value if it is not ?VARIABLE, otherwise, the maximum range value is used if it is not ?VARIABLE.

4) If the default value was not specified by step 2 or 3, then the default default value is used. This value is nil for type SYMBOL, "" for type STRING, 0 for type INTEGER, 0.0 for type FLOAT, [nil] for type INSTANCENAME, a pointer to a dummy instance for type INSTANCEADDRESS, a pointer to a dummy fact for type FACTADDRESS, and the NULL pointer for type EXTERNALADDRESS.

5) If the default value is being derived for a single field slot, then the default value derived from steps 1 through 4 is used. The default value for a multifield slot is a multifield value of length zero. However, if the multifield slot has a minimum cardinality greater than zero, then a multifield value with a length of the minimum cardinality is created and the default value which would be used for a single field slot is stored in each field of the multifield value.


next up previous