PEP-0315--Enhanced While Loop: An idea for an alternative syntax
Nicolas Fleury
nid_oizo at yahoo.com_remove_the_
Wed Feb 18 13:57:39 EST 2004
More information about the Python-list mailing list
Wed Feb 18 13:57:39 EST 2004
- Previous message (by thread): PEP-0315--Enhanced While Loop: An idea for an alternative syntax
- Next message (by thread): PEP-0315--Enhanced While Loop: An idea for an alternative syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Andrew Koenig wrote: > PEP 315 suggests that a statement such as > > do: > x = foo() > while x != 0: > bar(x) > > be equivalent to > > while True: > x = foo() > if x == 0: > break > bar(x) > > I like the overall idea, but wonder about the extra keyword. Moreover, if > you see > > x = foo() > while x != 0: > bar(x) > > you have to read backward to see whether the assignment to x is part of this > statement or part of a previous statement. > > I have a proposal for an alternative syntax that solves both of these > problems: > > while: > x = foo() > and while x != 0: > bar(x) I like the "while:" and "and while:" syntax, but I think the "or while" is confusing. I think it's worth an addition to PEP315 However, I remember reading Stroustrup saying he was not using the do-while at all (maybe in D&E, I'm not sure). Even if I have used do-while few times, I have the feeling it should not be added to Python at all, so I guess I'm in fact against PEP315, whatever the syntax. The reason is, if I say "do that while you're sleeping", is doesn't mean to me to do it at least once, even if not sleeping. It might explain why so much people are not using the do-while. This new syntax is interesting since it changes the vocabulary, but I think it's still unclear. The if-break method is only one line more (if the break is on a new line), and is pretty clear in meaning. However, there's things from C like += that I'm very happy to have in Python and there's still things I would like to have, like a ?: equivalent with a different syntax, but that's another story... Regards, Nicolas Fleury
- Previous message (by thread): PEP-0315--Enhanced While Loop: An idea for an alternative syntax
- Next message (by thread): PEP-0315--Enhanced While Loop: An idea for an alternative syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list