POV-Ray : Newsgroups : povray.general : while () { while () {}} doesn't work propertly. : Re: while () { while () {}} doesn't work propertly. Server Time
7 Aug 2024 13:20:01 EDT (-0400)
  Re: while () { while () {}} doesn't work propertly.  
From: Trevor Quayle
Date: 25 Sep 2001 16:36:10
Message: <3bb0eaba$1@news.povray.org>
> BTW: I don't like the ; semicolon after #declare. it seems so wrong for
> me, because it is a #directive that goes to the compiler. on C++, it
> will Not have ; semicolon.
>

I used to think the same, but there is a good reason why.
From the docs:
Note that there should be a semi-colon after the expression in all float,
vector and color identifier declarations. This semi-colon is introduced in
POV-Ray version 3.1. If omitted, it generates a warning and some macros may
not work properly.



try the following as a very simple example of why:

#macro Add3 (a,b,c)
  #declare ab=a+b;
  ab+c
#end

sphere{0 Add3(1,1,1) pigment{red 1}}

then remove the semi-colon and try again. It doesn't work because POV
doesn't truncate at the end-of-line so without the semicolon, it does not
know when tho end the declare in this case and the declare essentially
becomes:

"#declare ab=a+b ab+c"

ab+c becomes part of the decalre rather than being a separate operation.



-tgq




--
camera{location z*13look_at 0}light_source{15 15looks_like{sphere{0 10
}pigment{rgb 1}finish{ambient 15}}}union{torus{3,0.5rotate x*90}cone{y
*4,.5,-y*8,0}cone{-x*4,.5,x*8,0}pigment{rgb<.7,.6,.4>}finish{ambient 0
diffuse 0reflection{1fresnel on metallic 1}}interior{ior 25}rotate 15}
plane{y,-7pigment{checker rgb 0rgb 1scale 4}finish{diffuse.1}}//   TGQ


Post a reply to this message

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