Re: logical_true vs nothing in an if statment [message #85937 is a reply to message #85932] |
Thu, 19 September 2013 13:22   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
I work with an IDL programmer who uses LOGICAL_TRUE *everywhere* including statements like
if LOGICAL_TRUE(Keyword_set(flag)) then setflag,...
He said he has been burned too many times before on the definition of "truth", so he always uses LOGICAL_TRUE() even in cases where it is unnecessary, such as when the variable can only take on the values 0 and 1.
His code drives me crazy... --Wayne
On Wednesday, September 18, 2013 5:37:04 PM UTC-4, Paul van Delst wrote:
> On 09/18/13 16:22, Michael Galloy wrote:
>
>>
>
>> But, you can change this behavior in selected routines with the
>
>> logical_predicate compile option:
>
>>
>
>> IDL> for i = 0, 10 do if i then print, 'true' else print, 'false'
>
>> false
>
>> true
>
>> false
>
> ...etc...
>
>> IDL> compile_opt logical_predicate
>
>> IDL> for i = 0, 10 do if i then print, 'true' else print, 'false'
>
>> false
>
>> true
>
>> true
>
> ...etc...
>
>
>
> True (pun intended :o), and the OP should make sure the option is put in
>
> the procedure/function in question, not an IDL startup file!
>
>
>
> Also, what if someone writes code based on the false/true ping-pong
>
> behaviour, and then gives the code to someone else that DOES have the
>
> logical_predicate option set in a startup file?
>
>
>
> Would hilarity ensue?
|
|
|