[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GSoft BASIC Ramble
Mmm... I think I disagreed with this statement, although I do see your
point.
Leave and exit statement are not simply "goto statement without a line
number". They are structure and proper ways of leaving a loop when a
condition occurred, and goto 1 place only. Leave statement will only
leave and land itself at the statement immediately after the loop and
nowhere else - they are actually implemented to discourage probably
the only uses of Goto.
One of the often occurred condition is this: loop through a list of
objects, and something occurred (eg collision detection), leave the
loop. In many cases, For is often a better loop than Repeat and While,
and having a "leave" statement allows this to be implemented easily.
On 6月8日, 下午10时22分, Mike Westerfield <Mike...@aol.com> wrote:
> Strangely enough, the reason there is no leave or exit statement in
> Pascal is precisely because it is essentially a goto statement without
> a line number. Anyone who criticizes goto because it is not structured
> enough should not be using leave or exit, or break, continue and
> return in C (except for the last line of a function). One of the
> central tenants of structured programming was to have exactly one way
> in or out of a loop or procedure.