"Fossies" - the Fresh Open Source Software Archive

Member "gentle-97/html/exttypes.html" (20 Aug 1998, 1630 Bytes) of package /linux/misc/old/gentle-97.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the gentle-97.tar.gz project site itself.

HANDBOOK / GENTLE PRIMER / Using Types and Predicates Written in C /

External Types

An external type, i.e. a type whose values are not defined in Gentle, may be introduced by a type declaration without functor definitions.

By way of example, consider the declaration

   'type' IDENT
which introduces an external type IDENT.

Since in Gentle the values of this type are not specified they cannot be denoted by terms. On the other hand, values of an external type such as IDENT can be used in the same way as values of other types: they can appear as parameters of predicates and may be used as constituents of terms.

We could, for example, define a new type that introduces lists of IDENTs:

   'type' IDENTLIST
      list (IDENT, IDENTLIST)
and pass values of type IDENT as parameters as in

   'action' DeclareIdentList(IDENTLIST, TYPE)

   'rule' DeclareIdentList(list(Ident, IdentList), Type):
      DeclareIdent(Ident, Type)
      DeclareIdentList(IdentList, Type)

   'rule' DeclareIdentList(nil, Type)