POV-Ray : Newsgroups : povray.general : Re: Probably been asked... Why no power operator? : Re: Probably been asked... Why no power operator? Server Time
5 Aug 2024 12:19:07 EDT (-0400)
  Re: Probably been asked... Why no power operator?  
From: Josh Seagoe
Date: 17 Nov 2002 02:33:29
Message: <3dd74649$1@news.povray.org>
Warp wrote:
>   What you would have wanted is to make the unary minus to have a lower
> precedence. This would make "2^-3" illegal because a higher-precedence
> operator needs to be evaluated before the lower-precedence one and in
> this case it can't be done.

Ya know, this has been said before and I still don't see where it comes 
from.

In the case of a^-b, there is no choice as to what order the operation 
can be performed in, so precedence doesn't even come up.  Precedence 
isn't some rule that tells you what you can do, it just tells you which 
operation to perform first when you have a choice.

If you look in the manual for Bison, for example, operator precedence is 
a solution to an ambiguity.  When there's no ambiguity, the parser 
doesn't have to resort to checking precedence.  I understand POV's 
parser is probably different, but at least in an academic sense, the 
relative precedence of ^ and unary minus have no effect on a^-b.

-josh


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.