| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 8)

Working With General Types

The G2 general types are:

For those familiar with C, all values in G2 are implemented as pointers to data structures containing explicit type tags. All attributes and local names contain these pointers, so that G2 can always determine a specific type from the value itself.

Values declared as a general type specify that the value held in the local name or attribute will be one of the specific types that is a subtype of the general type. For example, if a local name is specified as a quantity, its value will be either an integer or a float, which are the subtypes of quantity.

Using the Item-or-Value Type

A value of type item-or-value represents a piece of information into which your KB can assign either an item or a value of a general, specific, or composite type.

Declaring a value of type item-or-value can add flexibility to some kinds of KB processing. Given a value of type item-or-value, your KB must determine the value's class or specific type before using it in a class-specific or type-specific expression.

Using the Value Type

A value of type value represents a piece of information that your KB can interpret as a number (that is, a quantity value, a float value, or an integer value), a symbol value, a text value, a truth-value value, a sequence, or a structure.

Using the Quantity Type

A value of type quantity represents a number that your KB can interpret as either type integer or float, depending on the processing context. This flexibility can be an advantage for some kinds of KB processing.

You can also assign a quantity value into a piece of knowledge declared with type quantity. After performing this assignment, however, for your KB to use the value that the assigned quantity now references, your KB must first use an expression to determine the specific type of the referenced value, integer or float. The KB can then use the referenced value in an expression or action.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 8)

Copyright © 1997 Gensym Corporation, Inc.