control structures (was "Re: Sins")

Phil Jensen pjensen at columbus.rr.com
Sun Dec 26 15:35:56 EST 1999


John Skaller quoted the following:

[and by the way, Viper and "environments" sound great.
I'm looking forward to this...]

> > > But 'break'
> > > in python isn't labelled, and there is no goto,
> > > so you end up having to use exceptions ... Uggghhhh.
> > 
> > Labeled breaks might well be a good idea, I guess.

and wrote:

JS> 	I'm not sure. I also have no candidate syntax
JS> for defining the labels. Labelled breaks give me
JS> an uneasy feeling.

I forget if I posted this before, but what I'd like to
see is the Zahn construct discussed in Knuth's article -
Pythonically:

    loop until "element found" or "search failed":
        ...
        if blah1 == blah2:
            "element found"
        ...
    when "element found":
        ...
    when "search failed":
        ...

Whatever the loop is, its exit or exits have some "meaning"
in the program, and this control structure encourages an
element of Literacy by forcing them to be named.

It deals with multiple exits, and multiple-level exits
very nicely.

(I've shown strings here because they allow more literacy
than identifiers, but they're still intended as mere tokens.
"elem" + "ent fou" + "nd" won't do it.)

IMHO, "break 3" would be awful.

  Phil Jensen





More information about the Python-list mailing list