[macstl-dev] IIf function -- opinions wanted
bob at redivi.com
Sun Mar 13 07:25:22 WST 2005
On Mar 12, 2005, at 3:11, Glen Low wrote:
> I'm rather partial to iif, although that and any variant that includes
> "if" in it may carry the false sense that a control flow is meant (as
> you said) i.e. that if_part is a boolean and either then_part or
> else_part is entirely selected and/or the other is not evaluated
> [control flow], rather than selecting elements of then_part and
> elements of else_part according to the elements of if_part [data
> flow]. Then again, && and || now operate on valarray and vec with data
> flow, even though the original meanings in C++ were control flow.
> I haven't been able to google out any other direct equivalents in
> other languages. It seems all the C descendants went for "if_part ?
> then_part : else_part", and all the Basic descendants and variants
> went for "iif (if_part, then_part, else_part)". Python seems to have
> an even stranger "if_part and then_part or else_part". Don't see any
> other "conditional select" data flow variants except Altivec's
Python's "if foo and bar or baz" is not on purpose, and isn't identical
to the equivalent in any other language because If bar is a false
value, then baz will be chosen regardless of foo. An actual Python
equivalent would be "if (foo and [bar] or [baz])", but really, in
Python you are just supposed to write it out.
More information about the macstl-dev