Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Argument starter - The roots of all evil
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00938079
Message ID:
00940467
Views:
29
>>>SNIP
>>>>
>>>>John,
>>>>
>>>>First of all, I don't consider myself an "expert". Rather I simply believe that if there's a reason that is quantifiable for breaking "the rules", then by all means do so.
>>>>
>>>>OTOH, I think that, in most cases, following the rules demonstrates a long term benefit.
>>>>
>>>>The thing is, in order to follow the rules and to know when to break them requires that the rules, and their purpose, are understood in the first place.
>>>
>>>George,
>>>
>>>Where is this "rule" that says EXIT/LOOP are WRONG?
>>>EXIT/LOOP, for instance, do NOT qualify for the "single exit point" rule because they are not exiting the module but simply exiting (or redoing) some looping construct.
>>>
>>Jim,
>>
>>IMV, they're the xBase equivalent of GOTO. That's me. I've never found a reason to use them.
>
>George,
>
>OK, that's your view.
>But for other readers of the thread I want to clarify something...
>
>EXIT/LOOP are in no way the equivalent of a GOTO, specifically in the way that structured programming specified the elimination of GOTO. In fact you'll find that EXIT/LOOP were added to languages to permit them to comply with structured programming specifications with simplification of code in the process.
>Structured programming prohibits GOing (JUMPing, BRANCHing, etc) from one 'module' to another EXPLICITLY, which is what GOTO and its derivatives (can) do (making for fine spaghetti but most difficult code reading/debugging).
>EXIT/LOOP, on the other hand, provide the ability to skip some code WITHIN a looping construct, EXIT going immediately to the next line after the looping construct and LOOP letting you resume the loop immmediately without executing code below itself. NOTE: Neither LOOP nor EXIT have any argument or parameter or operand so they can ONLY GO TO ONE DESTINATION EACH and THAT DESTINATION IS ALWAYS within the same module. Of course GO TO, JUMP, BRANCH etc ALL have to have an argument or parameter or operand (where to go) and such specification CAN GO ANYWHERE - within the same module or to another module.
>
Jim,

I misspoke when I said I never use EXIT. In certain situations, when there is no other choice, I do. For example, when searching a collection for a particular value when there is no other choice.

Now having said that, I should point out that even UCSD Pascal supports a GOTO statement. Does it mean it should be used regardlss of the evironment or circumstances. No! LOOP, in my mind, is totally useless unless extenuating circumstances (namely processing time) require it. Even though Tamar has indicated that there's an order of magnitutde difference between using a FOR...ENDFOR construct over a DO WHILE, I don't necessarily believe that it would apply in all cases. While her remarks were directed towards VFP 7.0 and above, in VFP 6.0 it took in excess of 10,000,000 iterations before more than 1/10th of a second was realized.

In my mind, both LOOP and EXIT change the flow of control. If they are not used when the situation warrents, both make the code harder to read and understand.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform