|
![](/i/fill.gif) |
"Warp" <war### [at] tag povray org> wrote in message
news:3d508498@news.povray.org...
> Pandora <pan### [at] pandora-software com> wrote:
> > Which you can fix with brackets (which also fixes all other
problems,
>
> Wrong. It doesn't fix the max(i++, j++) problem.
>
Ah, yes, true. That slipped my mind, but can be solved in the same way
as the efficiency issue, see below :
> > the efficiency issue (which'll more often than not get handled by
> > an optimising compiler anyway)).
>
> Wrong. For example if you call a function to get the value of the
> parameter, eg. max(function1(), function2()), the compiler can't optimize
> that double call away unless it can inline the function in question.
Easily solved by doing :
a=function1();
b=function2();
c=max(a,b);
> (And if the function *does* return a different value when called again,
the
> whole max() macro will simply give the wrong result for the exact same
reason
> as the max(i++, j++) gives a wrong result.)
also fixed by doing it in three stages, as above.
> Using the template solution fixes all problems.
>
Only if you have a compiler that allows you to use templates.
--
Pandora/Scott Hill/[::O:M:C::]Scorpion
Software Engineer.
http://www.pandora-software.com
Post a reply to this message
|
![](/i/fill.gif) |