Can't incremen int inside funciton call -- bug?

Regan Heath regan at netmail.co.nz
Tue May 29 06:25:01 PDT 2007


Aldarris Wrote:
> I have just found that the following:
> {recursiveXMLTreeIteration(childNode, (treeLevel + 1));}
> gives the desired result.

The () around treeLevel + 1 are unnecessary - unless you like the look or think it clearer to read.  The compiler will always completely evaluate the argument before passing it to the function.

The only time you need braces is when using operators of differing precedence where you want the lower (higher? not sure which term is used) precedence operator to apply first, eg.

  {recursiveXMLTreeIteration(childNode, treeLevel + 1 * 2);}

the * is evaluated first in the above, whereas with:

  {recursiveXMLTreeIteration(childNode, (treeLevel + 1) * 2);}

the + is evaluated first.

You probably know all that already but someone else might be interested :)

Regan 



More information about the Digitalmars-d mailing list