Am 20.09.2018 um 20:56 schrieb Kenneth:
>> #macro FormatKeyword(Format)
>> #if (Format = "png")
>> #elif (Format = "jpeg")
> A couple of questions/observations, though: The docs say two things at
> "188.8.131.52.1 The if...else...end Directives" (in v3.7.1 beta 9's help file--
> although I haven't yet checked the online wiki):
> "...an optional #elseif clause is now supported."
Whoops, my bad: It's `#elseif`. The construct isn't too uncommon in
programming languages, but the languages can't agree on whether it
should be `elseif`, `elsif` or `elif` (or a variation thereof as the
programming language's meta-structure permits, such as POV-Ray's `#elseif`).
Examples of Elseif-Languages:
- POV-Ray SDL
- Visual Basic
Examples of Elsif-Languages:
Examples of Elif-Languages:
- C/C++ Preprocessor
- Unix shell scripts
> The even shorter keyword #elif (for #elseif) is not mentioned there (even
> though it works); and, its keyword 'color' in scsne code looks like a
> 'non'-keyword. Should both of those little errors be fixed?
Actually, no, it doesn't work: That's a mirage. If you examine it more
carefully, you'll find that the construct only behaves as expected if
both the `#if` condition and `#elif` conditionoid happen to be false;
because in that case the bogus `#elif` statement will simply be skipped.
If the `#if` condition happens to be true, the parser will parse the
`#if` branch and then crash right into the `#elif` like a brick wall,
and if the `#elif` conditionoid happens to be true, the parser will
still skip over it and enter the `#else` branch.
> More importantly, I've never had a problem using nested #if's (when including
> all of the #else keywords, anyway.) I *think* my macro is a good demonstration
> of what the docs mean by nested #ifs as explained there(?) So are the new
> keywords #elseif and #elif designed to eliminate any *possible* nested-#ifs
> problems (along with being 'shorthand' versions of such constructs)? Just
Properly nested `#if` statements are not a problem. The problem
described in the docs specifically relates to nesting an `#if` in the
/condition/ of an enclosing `#if`.
Post a reply to this message