next up previous

11.2 ALLOWED CONSTANT ATTRIBUTES

The allowed constant attributes allow the constant values of a specific type which can be stored in a slot to be restricted. The list of values provided should either be a list of constants of the specified type or the keyword ?VARIABLE which means any constant of that type is allowed. The allowed-values attribute allows the slot to be restricted to a specific set of values (encompassing all types). Note the difference between using the attribute (allowed-symbols red green blue) and (allowed-values red green blue). The allowed-symbols attribute states that if the value is of type symbol, then its value must be one of the listed symbols. The allowed-values attribute completely restricts the allowed values to the listed values.

Syntax

<allowed-constant-attribute>
               ::= (allowed-symbols†<symbol-list>) |
                   (allowed-strings <string-list>) |
                   (allowed-lexemes <lexeme-list> |
                   (allowed-integers†<integer-list>) |
                   (allowed-floats†<float-list>) |
                   (allowed-numbers†<number-list>) |
                   (allowed-instance-names <instance-list>) |
                   (allowed-values†<value-list>)
<symbol-list>  ::= <symbol>+ | ?VARIABLE
<string-list>  ::= <string>+ | ?VARIABLE
<lexeme-list>  ::= <lexeme>+ | ?VARIABLE
<integer-list> ::= <integer>+ | ?VARIABLE
<float-list>   ::= <float>+ | ?VARIABLE
<number-list>  ::= <number>+ | ?VARIABLE
<instance-name-list>  ::= <instance-name>+ | ?VARIABLE
<value-list>   ::= <constant>+ | ?VARIABLE

Specifying the allowedlexemes attribute is equivalent to specifying constant restrictions on both symbols and strings. A string or symbol must match one of the constants in the attribute list. Type conversion from symbols to strings and strings to symbols is not performed. Similarly, specifying the allowednumbers attribute is equivalent to specifying constant restrictions on both integers and floats. In CLIPS 5.1, type conversion of integers to floats and floats to integers was performed when using the allowednumbers attribute (thus using allowednumbers was not equivalent to using both the allowedintegers and allowedfloats attributes together). In CLIPS 6.0, this type conversion is now longer performed. The allowedinstances attribute found in CLIPS 5.1 is no longer supported. The allowedinstancenames attribute should be used in its place.


next up previous