/ GENTLE PRIMER
/ Special Patterns and Expressions
In virtually all cases, the type of a particular position
is clear from the context. Hence one can use the same names for functors
of different types.
There is one exception where the type is not known: the parameter of ``generic'' predicates such as the built-in predicate where or user defined predicates of the category sweep.
For example, in
where(nil -> List)it is not clear what kind of list should be constructed if there are several types (say, ColorList and StatementList) that introduce nil.
To resolve the ambiguity, we can prefix the functor with the name of the type (followed by a single quote (`` ''')) as in
where(ColorList'nil -> List)The same holds for the first parameter of sweep predicates. For example, in
'sweep' Visit(ANY) 'rule' Visit(list(Head, Tail)): ProcessElem(Head) Visit(Tail)it is not clear whether the rule deals with values of type ColorList or StatementList if both types introduce the functor list. Again, we can prefix the ambiguous term:
'sweep' Visit(ANY) 'rule' Visit(ColorList'list(Head, Tail)): ProcessElem(Head) Visit(Tail)