@@ -142,33 +142,33 @@ Parameterized modules are QL's approach to generic programming.
142
142
Similar to explicit modules, parameterized modules are defined within other modules using the keywork ``module ``.
143
143
In addition to the module name, parameterized modules declare one or more parameters between the name and the module body.
144
144
145
- For example, consider the module ``ApplyFooThenBar ``, which takes two predicate parameters and defines a new predicate
145
+ For example, consider the module ``M ``, which takes two predicate parameters and defines a new predicate
146
146
that applies them one after the other:
147
147
148
148
.. code-block :: ql
149
149
150
- module ApplyFooThenBar <transformer/1 foo , transformer/1 bar > {
150
+ module M <transformer/1 first , transformer/1 second > {
151
151
bindingset[x]
152
- int apply (int x) {
153
- result = bar(foo (x))
152
+ int applyBoth (int x) {
153
+ result = second(first (x))
154
154
}
155
155
}
156
156
157
157
Parameterized modules cannot be directly referenced.
158
158
Instead, you instantiate a parameterized module by passing arguments enclosed in angle brackets (``< `` and ``> ``) to the module.
159
159
Instantiated parameterized modules can be used as a :ref: `module expression <name-resolution >`, identical to explicit module references.
160
160
161
- For example, we can instantiate ``ApplyFooThenBar `` with two identical arguments ``increment ``, creating a module
161
+ For example, we can instantiate ``M `` with two identical arguments ``increment ``, creating a module
162
162
containing a predicate that adds 2:
163
163
164
164
.. code-block :: ql
165
165
166
166
bindingset[result] bindingset[x]
167
167
int increment(int x) { result = x + 1 }
168
168
169
- module IncrementTwice = ApplyFooThenBar <increment/1, increment/1>;
169
+ module IncrementTwice = M <increment/1, increment/1>;
170
170
171
- select IncrementTwice::apply (40) // 42
171
+ select IncrementTwice::applyBoth (40) // 42
172
172
173
173
The parameters of a parameterized module are (meta-)typed with :ref: `signatures <signatures >`.
174
174
0 commit comments