I have multiple views on this "category" of inquiry:

I think only an engineer at RocketSoftware can answer this question.

Some people actually use the non-optimization to their benefit. They
count on the fact that the expression will be evaluated on every
iteration, whether it's a DCount, Field, or some other calculation.
Changing this could break applications.

Evaluation of expressions might be dynamic - they might only
re-evaluate if they need to. The BASIC runtime could setup a dirtyFlag
on loops with an expression as an operand. If any component of the
expression changes, set the flag. Next time through the iterator check
the dirtyFlag. If it's set, then the expression must be re-evaluated,
else use the previous value. However, a new problem here is that now
there is a special check being set on every variable assignment, which
can be a performance issue in itself. More variables involved in the
expression means more runtime checks and performance can become worse
than if it were just re-evaluating the one expression on every loop.

This falls into the category of "be careful what you wish for, you may
get it". My bottom line is that we should strive for more options to
define and override behaviors like this. We should have the option to
make code behave as we expect, using compiler directives - and if a
developer doesn't understand the options they're using, that's their
problem, not a platform issue. THAT is what we should ask for when
looking for features. It's not so much "how it works", but knowing if
it's possible to change behavior so that the runtime processes our
code the way we want.


Tony Gravagno   
Nebula Research and Development         
TG@ remove.pleaseNebula-RnD.com         
Nebula R&D sells mv.NET and other Pick/MultiValue products      
worldwide, and provides related development services    
http://Nebula-RnD.com/blog      
Visit http://PickWiki.com! Contribute!          
http://Twitter.com/TonyGravagno         
http://groups.google.com/group/mvdbms   


> From: Peter Cheney 
> Does a DCOUNT get evaluated again for each iteration of a loop?
> Or is UniVerse these days intelligent enough to keep track of what's
> going on?
> 
> e.g.
> 
> for i = 1 to dcount(array,@fm)
>    *commands here
> next i
> 
> versus
> 
> totalattributes = dcount(array,@fm)
> for i = 1 to totalattributes
>    *commands here
> next i
> 
> Apart from readability and perhaps easier debugging is there an
actual
> internal difference?
> I know it was an issue on older pick releases but I cannot remember
if
> it ever affected UV?


_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to