Re: EOF and GOTO and 0th array element

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hello Igor,
either I didn't explain myself clearly enough or you missed reading the
section where I added an alternative to 'exit n'.

----- Original Message -----
From: "Igor Kachan" <kinz at peterlink.ru>
To: "EUforum" <EUforum at topica.com>
Subject: Re: EOF and GOTO and 0th array element


>>
> Derek <ddparnell at bigpond.com> wrote:
>>
>> <snip>
>> > I will argue against the "exit n" idea for
>> > a number of reasons.
>> > The first reason is that over time, the value
>> > of 'n' might change as
>> > modifications change the nesting level
>> > of the 'exit' statement.
>
><snip>

It is in the snipped part that I put forward an alternative to 'exit n'.
Maybe you would like to reread that section to see a fuller discussion.

In summary it is this: A simple way to exit deeply nested loops is a
desirable addition to the language. The idea of 'exit n' where 'n'
represents the current depth level is NOT the best idea. ****INSTEAD**** I
would propose that 'exit <name>' be used, where <name> is the name the
programmer gives to a specific loop block.

The reason is that the depth can change over time as the program is
modified, but a named loop block is unlikely to have a name change.

>This 'n' must be considered if it is 3 or more.
>
>For 1 and 2, there are the simple old good
>standard antispaghetti EU constructions,
>for example:
>

Here is my reworking of your example:

      FileBlk:while x do
        -- code 1
        RecordBlk:while y do
            -- code 2
            if a then exit FileBlk
                 else exit RecordBlk
            end if
            -- code 3
        end while
        -- code 4
            if b then exit FileBlk
            end if
     end while

As you can see, this scheme works just as well for any depth level of loop
block nesting. And even if some programmer later changes the depth level,
the code ALREADY written does not need changing per se.

>So, the question is - how frequently we use
>3 and more nested loops - as a reason to
>implement exit n.
>
>This question has to have a simple answer -
>let us search through 930+ archive packages
>to find this too deep loops' percentage.
>
>But I am too too lazy to search and to struggle
>for this >=3 new feature in the interpreter,
>sorry please, OK?  blink
>
>Who wants?

As I have now explained (again) that sort of exercise is not required.

It is not the concept of exiting an arbitary depth of loops that I have
issue with, its the idea of enumerating that level on an 'exit' statement
that troubles me.

----------------
cheers,
Derek Parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu