Difference between revisions of "PrF UG slots value type any"
(Automated import of articles) |
|||
Line 11: | Line 11: | ||
[[PrF_UG_slots_value_type_integer|Integer]], | [[PrF_UG_slots_value_type_integer|Integer]], | ||
[[PrF_UG_slots_value_type_string|String]], | [[PrF_UG_slots_value_type_string|String]], | ||
− | or | + | or [[PrF_UG_slots_value_type_symbol|Symbol]]. |
− | [[PrF_UG_slots_value_type_symbol|Symbol]]. | + | <b>Any</b> allows you to create a generic slot for a high-level class |
− | <b>Any</b> allows you to create a generic slot for a high-level class and then determine the actual value type at a lower level. | + | and then determine the actual value type at a lower level. |
If a class inherits a slot of type <b>Any</b>, | If a class inherits a slot of type <b>Any</b>, | ||
Line 19: | Line 19: | ||
This is the only case where the actual value type of an inherited slot can be changed. | This is the only case where the actual value type of an inherited slot can be changed. | ||
− | For example, | + | For example, suppose you are modeling a taxonomy for all the vertebrates in an ecosystem, |
− | suppose you are modeling a taxonomy for all the vertebrates in an ecosystem, | ||
with specific species as the instances. | with specific species as the instances. | ||
You could create the slot <b>Diet</b> at the <b>Vertebrate</b> class level. | You could create the slot <b>Diet</b> at the <b>Vertebrate</b> class level. | ||
Line 34: | Line 33: | ||
<li><p> | <li><p> | ||
for the subclass <b>Herbivore</b>, | for the subclass <b>Herbivore</b>, | ||
− | you could restrict the <b>Diet</b> slot to type <b>Symbol</b> and list possible food plants by name | + | you could restrict the <b>Diet</b> slot to type <b>Symbol</b> |
+ | and list possible food plants by name | ||
</p> | </p> | ||
</ul> | </ul> |
Revision as of 16:58, October 16, 2008
The Any Value Type
A value type of Any means the slot can take any one of the other values: Boolean, Class, Float, Instance, Integer, String, or Symbol. Any allows you to create a generic slot for a high-level class and then determine the actual value type at a lower level.
If a class inherits a slot of type Any, then the slot may be modified by restricting it to one of the other types. This is the only case where the actual value type of an inherited slot can be changed.
For example, suppose you are modeling a taxonomy for all the vertebrates in an ecosystem, with specific species as the instances. You could create the slot Diet at the Vertebrate class level. Then:
for the subclass Carnivore, you could restrict the Diet slot to type Instance, so that you could select specific species already in your taxonomy as the diet
for the subclass Herbivore, you could restrict the Diet slot to type Symbol and list possible food plants by name
A class that has a slot of type Any cannot have instances.