POV-Ray : Newsgroups : povray.general : fundamental question re: #switch/#case/#break : Re: fundamental question re: #switch/#case/#break Server Time
30 Jul 2024 00:25:04 EDT (-0400)
  Re: fundamental question re: #switch/#case/#break  
From: Kenneth
Date: 25 Nov 2010 04:25:01
Message: <web.4cee283f2f7b65a8196b08580@news.povray.org>
> <jeb### [at] freefr> wrote:

>  You're right, there is a mistake in the doc. The first statement is
> correct: if the condition is true, then parsing continues until a
> #break, #else or #end (unless that #break, #else or #end is
> associated with another control statement such as #if or #while).
>
>  The second statement is wrong: when the parsing falls through to
> the next #case or #range, that clause conditional is *ignored* and
> the following statements are parsed as if the conditional were true.
>

In addition to this correction, I believe it would be helpful to have the 2nd
paragraph explicitly state that, when using no #breaks, a *series*
of #case's or #range's can produce 'cascading TRUE' behavior. (As I found out in
my example.) The WIKI calls it a 'slip-through' if I'm not mistaken. To most
folks in the POV-Ray community this is probably obvious--from the
wording of the docs above or from other coding experience. But I just didn't
grasp it that way initially (am I alone?)

Something like,
"For example, if you use a series of #case or #range clauses with no #breaks
in-between, the first clause that evaluates TRUE will force all subsequent
clauses to evaluate TRUE as well (regardless of their intrinsic TRUE/FALSE
conditional state), in a sort of cascade--until a #break/#else/#end is
encountered." Or something similar.

That might sound like I'm 'dumbing-down' the documentation; but with such an
addition, I would probably have understood these concepts better, from the
get-go.

Ken


Post a reply to this message

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