Infinite context loop?

Posted by Tim Kuehn on 01-Dec-2006 15:16

I'm checking out the context code from the PDSN library, and came across this:

in function fetchContextPage in file proSIserver.p:

DO WHILE ContextStore.SessionID = "" AND

ContextStore.ContextID = pcContextID AND

ContextStore.ContextName = phPageTable:NAME AND

ContextStore.RowSequence < iStartSeq + piPageSize:

/* stopped coding here... */

END.

I'm thinking this looks an awful lot like an infinite loop....

All Replies

Posted by Thomas Mercer-Hursh on 01-Dec-2006 15:33

Why?

Seems like this clause would certainly limit the number of rows:

ContextStore.RowSequence

Not to mention that, even without that, there are only going to be so many records in ContextStore which qualify:

ContextStore.SessionID = "" AND

ContextStore.ContextID = pcContextID AND

ContextStore.ContextName = phPageTable:NAME

Posted by Tim Kuehn on 01-Dec-2006 15:37

Ummm - there's nothing inside the loop to change any of those values...the comment is the only "code" between the DO WHILE and END.

Either the loop is skipped completely because the AND conjunctions fail, or it never leaves.

Posted by Thomas Mercer-Hursh on 01-Dec-2006 16:43

Ah, so you are saying that the comment is the only content of the loop and there is nothing to advance to the next record?

The corresponding procedure in AutoEdge looks like this:

--


--


Posted by Tim Kuehn on 01-Dec-2006 18:25

Ah, so you are saying that the comment is the only content of the loop and there is nothing to advance to the next record?

Exactly.

Posted by Thomas Mercer-Hursh on 01-Dec-2006 18:35

Hopefully, the version from AutoEdge makes a bit more sense!

Posted by Tim Kuehn on 01-Dec-2006 21:08

Hopefully, the version from AutoEdge makes a bit more sense! :)

I can only guess - this code isn't supposed to actually do something, just illustrate a principle...

Posted by Thomas Mercer-Hursh on 02-Dec-2006 10:53

Was that the principle of how to use up as many CPU cycles as possible?

The AutoEdge version makes a certain intuitive sense to me, just from the dictionary, but I haven't studied it enough yet to see whether or not I agree with the design.

This thread is closed