There are now three types of pattern clauses:
In while and if patterns, we are looking at matching control variables. A control variable is a variable that is used in the conditional expression of a container statement.
While pattern and if pattern has 2 arguments and 3 arguments within the parenthesis respectively.
_
_
.Example:
procedure p {
1. if (1 == 2) then {
2. while (3 == 4) {
3. x = 1; } }
else {
4. if (x == 1) then {
5. while (y == x) {
6. z = 2; } }
else {
7. y = 3; } } } }
The following queries will yield these answers:
if ifs; while w;
Select ifs pattern ifs(_,_,_)
will return 4
, as only stmt 4
is a if statement uses variable(s) in conditional expressionSelect w pattern w(_,_)
will return 5
as only stmt 5 is a while statement uses variable(s) in conditional expressionSelect <ifs, v> pattern ifs(v,_,_)
will return 4 x
Select <w, v> pattern w(v,_)
will return 5 x, 5 y