Jerry Coffin
11/2/2008 5:06:00 AM
In article <97be6af8-1d3a-4e82-9a4f-751377740b86
@z6g2000pre.googlegroups.com>, silverburgh.meryl@gmail.com says...
> Hi,
>
> I need some help in understanding the following for() loop:
>
> for (PRBool isRoot;
> mCSSUtils->IsRuleNodeRoot(ruleNode, &isRoot), !isRoot;
> mCSSUtils->GetRuleNodeParent(ruleNode, &ruleNode))
>
> what is the middle clause for?
> Why there is a ',' in the middle? And what does that mean?
It looks like this is attempting to traverse from a current node to a
root node in a threaded tree, or something on that general order.
The middle clause is a test, just like usual. The comma operator
evaluates its left operand, discards the result, then evaluates the
right operand. The result of the right operand becomes the result of the
whole expression.
In this case, it's calling "IsRuleNodeRoot", which apparently looks at a
node, figures out whether it's a root node, and sets some sort of semi-
boolean (a pointer to which is passed as a the second parameter) to tell
you that result. In this case, that variable (isRoot) is evaluated as
the right operand of the comma operator, so what it's doing it calling
the function to set the variable, then evaluating the variable itself to
determine whether it's reached the root yet, and continuing the loop
until it reaches the root.
--
Later,
Jerry.
The universe is a figment of its own imagination.