POV-Ray : Newsgroups : povray.general : fundamental question re: #switch/#case/#break : Re: fundamental question re: #switch/#case/#break Server Time
29 Jul 2024 18:20:30 EDT (-0400)
  Re: fundamental question re: #switch/#case/#break  
From: Kenneth
Date: 22 Nov 2010 20:05:00
Message: <web.4ceb0f2c2f7b65a8196b08580@news.povray.org>
Jim Holsenback <jho### [at] povrayorg> wrote:

> If you're using 3.7betas (for some reason i think/thought you were)
> there has been a change in behavior noted here:
>
>
http://wiki.povray.org/content/Documentation:Tutorial_Section_1#Changes_and_New_Features_Summary
>
> search for (browser find) break on that page, and the link will
> eventually get you to the page you mentioned above. This is our MOST up
> to date documentation as with regards to v3.7 ....

I'm still with 3.6.1c (but I assume that the *basic* operation of #case/#break
hasn't changed since then?)

If the link you mentioned is the latest WIKI documentation, it matches most of
the wording in my 3.6.1 included documentation, and is the prime source of my
puzzlement. Here's why:

The WIKI (updated 14 October 2010) at
http://wiki.povray.org/content/Documentation:Reference_Section_2.5#The_.23switch.2C_.23case.2C_.
23range_and_.23break_Directives

says, "if the [#case} clause's condition is true, that clause's tokens are
parsed normally and parsing continues until a #break, #else or #end directive is
reached. If the condition is false, POV-Ray skips until another #case or #range
is found."

and

"If a clause evaluates true but no #break is specified, the parsing will fall
through to the next #case or #range and that clause conditional is evaluated."

The words 'skip' and 'evaluate' seem clear and co-consistent as to what *should*
happen (*IF* I'm understanding them correctly.) Here's how I read the quoted
statements in relation to the simple code example I posted:

Given:

#while(counter <=3) and the situation where counter actually equals 2,

I would expect that, without using any #breaks, #case(1) would be 'evaluated' as
FALSE and 'skipped' (no action there), leading to #case(2) being 'evaluated' as
TRUE, then #case(3) being 'evaluated' as FALSE and 'skipped'--with the sum total
of these evaluations being that only the #case(2) scaling (its token) is applied
to my box, as it's the only TRUE evaluation. But this isn't what happens;
instead, the behavior *seems* to match the outdated(?) WIKI section that says,
"When processing a matching #case or #range clause, if a #break is not
encountered it continues through successive #case statements whether they match
or not." I.e., any following #case() tokens are applied whether those #cases are
TRUE *or* FALSE.

See my conundrum? Of course, my little code problem can easily be fixed with
some #break clauses. But I'm FAR more concerned with my own lack of
understanding of the logic of this situation.

Ken


Post a reply to this message

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