[macstl-dev] IIf function -- opinions wanted

Bob Ippolito bob at redivi.com
Sun Mar 13 07:25:22 WST 2005

  • Previous message: [macstl-dev] IIf function -- opinions wanted
  • Next message: [macstl-dev] gcc 3.3 on YellowDogLinux
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]


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 
> vec_sel.

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])[0]", but really, in 
Python you are just supposed to write it out.

-bob




  • Previous message: [macstl-dev] IIf function -- opinions wanted
  • Next message: [macstl-dev] gcc 3.3 on YellowDogLinux
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

More information about the macstl-dev mailing list