What if....

Peter Haworth pete at lcsql.com
Sun Jan 27 14:45:16 EST 2013


OK, so I understand the parens thing now.  Any thoughts on the use of
multiple ifs vs joining the conditions together with "and".  I've
always considered that to be just a matter of personal preference and ease
of reading but wondering if there might be other implications, like
performance for example.

Pete
lcSQL Software <http://www.lcsql.com>


On Sun, Jan 27, 2013 at 11:27 AM, J. Landman Gay
<jacque at hyperactivesw.com>wrote:

> On 1/27/13 12:39 PM, Peter Haworth wrote:
>
>> Musings about complex if statements on this Sunday morning....
>>
>> Lets say you have a complex if statement with 4 conditions that must all
>> be
>> true.  Is there any advantage, other than personal preference/style, to:
>>
>> if cond1 and cond2 and cond3 and cond4 then.....
>>
>> or
>>
>> if cond1 then
>>     if cond2 then
>>        if cond3 then
>>           if cond4 then...
>>
>> In either case, as soon as a condition evaluates to false, none of the
>> rest
>> are evaluated, right?
>>
>
> Right, both examples are equivalent. In the single line version (example
> 1) the conditions are evaluated left to right, and as soon as one is false
> the rest are abandoned.
>
> Parentheses indicate which conditions are part of a grouping but don't
> influence the direction of evaluation.
>
> --
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
>
>
> ______________________________**_________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
>



More information about the use-livecode mailing list