Re: [Vala] Small syntax request labeled loops



Ed Schouten wrote:
* Arto Karppinen <exeonical mail suomi net> wrote:
If you have a lot of loops inside one another, it needs some figuring out which loops happens to be number 2 at any given point.

I bet the compiler already stores references to the current, but also
the parent scope.


I was thinking this from the programmers point of view. A piece of code which breaks second loop, is not as easy to read, than say a code that breaks loop pixels.

The problem with numeric break, is that the number of loops is counted from outside to the inside: Heres an example.

/* Loop alpha */
for (i = 1; i < 10; $i++) {
        
        /* Loop beta */
        for (i = 1; i < 10; $i++) {

                /* Loop charlie */
                for (i = 1; i < 10; $i++) {

                        /* Loop delta*/
                        for (i = 1; i < 10; $i++) {
                                
                                /* This breaks charlie. */
                                break 2;
                        }

                        /* This breaks beta */
                        break 2;
                }

                /* This breaks alpha */
                break 2;
        }

        /* This should cause an error. */
        break 2;
}

So break 2 means different things depending on where it is. Which is confusing. So the perl syntax is more expressive, and easier to read.


--
Arto Karppinen
------------------------------
arto karppinen iki fi



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]