Skip to content

Commit b68f9f7

Browse files
author
Shati Patel
committed
QL HB: Add bindingset example
1 parent 7e84453 commit b68f9f7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

docs/language/ql-handbook/predicates.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,20 @@ Multiple binding sets specified this way are independent of each other. The abov
271271
- If ``y`` is bound, then ``x`` and ``y`` are bound.
272272

273273
That is, ``bindingset[x] bindingset[y]``, which states that at least one of ``x`` or ``y`` must
274-
be bound, is different from ``bindingset[x,y]``, which states that both ``x`` and ``y`` must be
274+
be bound, is different from ``bindingset[x, y]``, which states that both ``x`` and ``y`` must be
275275
bound.
276276

277+
The latter can be useful when you want to declare a :ref:`predicate with result <predicates-with-result>` that takes multiple input arguments::
278+
279+
bindingset[a, b]
280+
int getSum(int a, int b) {
281+
result = a + b
282+
}
283+
284+
You can then use this in a :ref:`select clause <select-clauses>`, for example::
285+
286+
select getSum(3, 5)
287+
277288
.. _database-predicates:
278289

279290
Database predicates
@@ -283,7 +294,7 @@ Each database that you query contains tables expressing relations between values
283294
("database predicates") are treated in the same way as other predicates in QL.
284295

285296
For example, if a database contains a table for persons, you can write
286-
``persons(x, firstName, _, age)`` to constrain ``x``, ``firstName`` and ``age`` to be the
297+
``persons(x, firstName, _, age)`` to constrain ``x``, ``firstName``, and ``age`` to be the
287298
first, second, and fourth columns of rows in that table.
288299

289300
The only difference is that you can't define database predicates in QL. They are defined by the

0 commit comments

Comments
 (0)