Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Intellisense in WITH ... ENDWITH
Message
De
06/09/2012 15:29:11
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
02/09/2012 04:29:12
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01550535
Message ID:
01552506
Vues:
67
Hi Walter

That "impact on performance" has got to be on par with mdot. With has risks. mdot usage has no risk. So, since I have yet to see any significant impact solved by WITH...ENDWITH instead of loading to a memvar first, I'll continue to avoid it.

>One aspect has been not been considdered IMO.
>
>In our framework we sometimes do rely on Access methods on properties to get references to e.g. biz objects. Using WITH will only once execute the access method and therefore will have a significant performance advantage. Of course you can achieve the same if you load the property into a variable first.
>
>Perhaps related aspect is that WITH and ENDWITH was demonstrated to have usage in deep COM hierarchies where it might have a significant impact on performance.
>
>Walter,
>
>
>
>
>>>>That is actually the reason I abandoned using WITH alltogether. I realized it is making the code more unclear to read (especially when you have more than 20 lines of code, or, worse, when you put different WITH's in the same code). Most other languages don't have that WITH either, I know if from VBA, but it is absent from C# and Java for instance (afaik). It appears to me as some kind of relic of older days, something that seemed to be a good idea back then. But then again, when it was introduced there was no intellisense at all.
>>>
>>>IIRC, the code is supposed to run faster, because all the commands inside the block have a context where to look for variables. I.e. instead of looking through the regular lists (current alias, public variables, private variables, local variables), it goes only through the PEMs of the WITH object. Should be easy to test in the usual loop. And the effect should be prominent if the WITH expression goes three dots deep.
>>>
>>>I didn't test this for many years, but it's possible that it still holds true. I habitually do that if I have to reference some number of PEMs of the same object in a tight loop.
>>
>>Hi Dragan
>>
>>I found there is no performance benefit of WITH vs a memvar. After a few runs, the memvar approach averages out to be slightly faster.
>>
>>LOCAL oForm, lcName, lnX, lnA
>>oForm = CREATEOBJECT("Form")
>>oForm.Name = "Dragan"
>>
>>lnA = SECONDS()
>>WITH m.oForm
>> FOR lnX = 1 TO 1000000
>> lcName=.Name
>> ENDFOR
>>ENDWITH
>>?SECONDS()-m.lnA,"with..."
>>
>>lnA = SECONDS()
>>FOR lnX = 1 TO 1000000
>> lcName=m.oForm.Name
>>ENDFOR
>>?SECONDS()-m.lnA,"memvar..."
>>
>>The next bit of code is what really bugs me about WITH. If from within the with, one calls a prg/udf of whatever where one accidentally left out the object reference, even by adding a period by mistake, the ?.Name will resolve all the way back to the last WITH. That's not explicitly clear and I have seen and debugged exactly such a thing and it was tiresome to say the least. Have not used with in years, still see no value in it whatsoever. With only saves typing that can just as easily be done with copy/paste.
>>
>>WITH m.oForm
>>?Junk()
>>ENDWITH
>>
>>PROCEDURE junk
>>?.Name
>>RETURN
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform