Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Iif(lExp, .t., .f.)?
Message
From
22/01/2010 13:21:18
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01445223
Message ID:
01445514
Views:
56
>>>Perhaps YOU know where you are, but what's the harm of writing = .T. in such a case. Or stated in other words: Would you think derogative of another programmer when you saw such a line in his/her code?
>>
>>Yes. If I saw that form regularly in the code, I'd think the programmer didn't know it was unnecessary.
>
>Tamar, I'm referring now to the case of THIS.VALUE only, not to all cases. If you'd see that the programmer does not use = .T. in all cases except for the THIS.VALUE cases, would you even then think negative of that programmer?

I'd wonder whether that programmer understood that This.Value was sufficient.


>>That said, I did test this stuff for an Ask Advisor piece a few years (Jan. '06 issue), and found that it doesn't have a performance effect.
>>
>>However, using an IF to assign a logical value to a variable rather than just assigning the expression was slower.
>
>I often assign a property's value to a local variable that will be used in the rest of that code more times. E.g.
ldStartDate = this.parent.dSDate
>for ln = 1 to 10
>    ? m.ldStartDate + m.ln
>next
One reason is that it gives me the chance to write easier readable code. But also I have the hunch that it may be slower to retrieve this.parent.dSDate x times than the local variable. Is this hunch valid? Or is it just me.

The case I'm talking about is:
IF <some logical expression>
  lVar = .T.
ELSE 
  lVar = .F.
ENDIF
rather than:
lVar = (<some logical expression>)
Truth is, I find the first more readable, but my tests showed the second is faster.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform