|
|
Kenneth schrieb:
> Is it *possible* that macros-within-macros, each using #if
> blocks--some WITH an #else statement and some without--might create a problem
> for POV's core code trying to determine which #else statement to use for which
> macro?
No, unless there would be a serious bug somewhere in there.
Such things can happen in languages where the if statement does not
necessarily open a statement block, but can be followed by a single
statement, and the else clause is optional, as in C, allowing for the
syntax variants
if (CONDITION) STATEMENT
if (CONDITION) STATEMENT else STATEMENT
as shorthand for
if (CONDITION) { STATEMENT }
if (CONDITION) { STATEMENT } else { STATEMENT }
causing ambiguity whenever the shorthand form is used in nested if
constructs with some else clause being omitted:
if (CONDITION) if (CONDITION) STATEMENT else STATEMENT
By definition the else is then attributed to the last if, which may or
may not be the intended behavior.
However, this cannot happen in POV-Ray, as each #if statement must
always be matched by an #end, so there is never any ambiguity which #if
an #else belongs to.
You can still confuse the parser by forgetting the #end for an #if, but
in this case the parser will notice that something is bogus:
#if (foo)
#if (bar)
execute_if_foo_and_bar()
/* #end forgotten here */
#else
execute_if_not_foo()
#end
/* parser will complain about a missing #end here */
As #end is also used to terminate macros, there's also no way to define
partial #if statements in a macro.
Post a reply to this message
|
|