[NEXT] [PREV]    HANDBOOK / GENTLE PRIMER / Smart Traversal /

Threaded Parameter

Gentle
Applications
Concepts
Examples
Handbook
Support
Download

A sweep predicate may also have an additional input and an output parameter, which must then both be of the same type:

  • 'sweep' P ( ANY, T -> T )
In the default rule, the parameter is threaded through the arguments (the input of a member is the output of its predecessor):
For example, to count all identifier applications, we can write

   'root' Program(-> Pgm) Count(Pgm, 0 -> N) print(N)

   'sweep' Count(ANY, INT -> INT)
      'rule' Count(id(Id, Pos), N -> N+1)




[NEXT] [PREV]