|
|
"Bald Eagle" <cre### [at] netscapenet> wrote:
>
> I see where it's going wrong, and this will give you an idea of why:
>
> #switch(true)
>
> #case(1)
> rgb <0, 0, 0.2>
> #break
>
> #case(
> // no (strcmp(IMG_TYPE,AA), which is the only 'correct' match
> (strcmp(IMG_TYPE,BB))
> | (strcmp(IMG_TYPE,CC))
> )
>
> #switch(true) is a very strange usage, and I'm sure clipka could give some
> source-code explanation of why it works the way it does.
> But basically, as I suspected, it just selects the FIRST #case() regardless of
> what it is.
But here's a very similar example (though without any ORs, which might make all
the difference), and it selects the 2nd #case (green)...
#switch(true)
#case(0)
rgb <0, 0, 0.2> // BLUE
#break
#case(1)
rgb <0,1,0> // GREEN
#break
....
This makes sense to me (well, at the moment, anyway!), as it looks like
#switch(true) is picking the #case with the appropriate 'true' result of (1)
>
> In fact, check out:
>
> #switch(strcmp(IMG_TYPE,BB) | strcmp(IMG_TYPE,CC) )
>
> #case(-10)
> rgb <1, 1, 0>
> #break
>
> #case(-6)
> rgb <1, 1, 1>
> #break
>
> #case(1)
> rgb <0, 0, 0.2>
> #break
>
> #case(1000)
>
> It selects the blue pigment, which corresponds to 1.
*That's* a really unexpected result, IMO; neither of the #switch's strcmp()s
'match' IMG_TYPE (which would be AA), yet #case(1) is chosen as if #switch is
'true.' And looking at it in a different brain-twisting way (one that's
incorrect, no doubt), it seems that either #case(-6) or #case(-10) should be
chosen, but certainly not #case(1)
It all makes my brain hurt :-O
Post a reply to this message
|
|