Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To iif or not to iif = .t.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00513276
Message ID:
00514633
Views:
11
>>Jim,
>>
>>>Acknowledging that your example is overly simplified, it's just fine for the LOOP condition (I would code the simpler cases this way too) but not so good for EXIT, as it essentially makes a forced completion of the WHILE. This could be very wasteful if processing records and there are more that satisfy the WHILE.
>>>
>>>After your last I went on a brief search using GOOGLE to check out 'structured programming loop exit'. What was there was generally older (pertaining to when LOOP/EXIT (or similar) were introduced into various languages). Most entries said that they (LOOP/EXIT) were added to facilitated structured programming! A couple acknowledged that some contended that this was not in keeping with structured programming, but they seemd definitely in the (very) minority.
>>>
>>>It tended to confirm in my mind that their usage was perfectly acceptable.
>>>
>>It should be pointed out that even the ISO Pascal Standard included the GOTO statement. I'm am of the opinion that its inclusion was an acknowledgement that it it may not be possible in all situations. To quote from the Third Edition of the User Manual and Report:
>>
>>"A goto statement should be reserved for unusual or uncommon situations where the natural structure of the algorithm has to be broken. A good rule is to avoid the use of jumps to express regular iterations and condition execution of statements, for such jumps destroy the reflection of the structure of computation in the textual (static) structures of the program. Moreover, the lack of correspondence between the textual and computational (static and dynamic) structure is extremely detrimental to the clarity of the program and makes the task of verification much more difficult. The presence of goto's in a Pascal program is often an indication that the programmer has not yet learned "to think" in Pascal (as the goto is a necessary construct in some other programming languages)." - Kathleen Jensen/Niklaus Wirth
>
>Yep, this is much along the lines of the writeups I read through GOOGLE. Does that PASCAL include LOOP/EXIT (or derivatives) and, if so, is there a similar pronouncement on them (this was, after all, about GOTO)?

Standard Pascal does not (or at least did not). However, some compilers allowed the programmer to change the value of the for iteration structure's control variable. This could be used to pre-maturely terminate the structure. This was in violation of the standard, and, according to Lampley, Macdonald and Roberts in their "Programming Principles Using Pascal" book, "...doing so is a poor programming practice and is to be avoided."

The Jensen/Wirth quote above can easily be applied to LOOP/EXIT for the same reasons, however.

>As I said, the extracts I read all essentially said that LOOP/EXIT were added to conform to structured programming. There were also a few opposing views.
>I guess you are one with those views too.
>
I would say so. I should note, however, that it has been more than 10 years since I worked in Pascal. While I don't doubt that the standards have changed since then (we have Object Pascal now), I would doubt that anything as fundamental as this would change.
George

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

Click here to load this message in the networking platform