Loop until condition is true
Grant Edwards
grante at visi.com
Sat Jun 18 09:35:16 EDT 2005
On 2005-06-18, Peter Otten <__peter__ at web.de> wrote:
>> If you look at C code, at least in my experience the
>> "until" loop is quite rarely used. (I don't see it once in the source
>> to Python 2.4, for example.)
>
> Long time no C?
>
> 'until' in C is actually
>
> do
> statement
> while (expression);
>
> I found 136 occurrences of "do {" versus 754 of "while (" and 1224 of "for
> (" in the Python 2.4 source, so using these rough estimates do-while still
> qualifies as "rarely used".
AFAICT, the main use for do/while in C is when you want to
define a block of code with local variables as a macro:
#define DoSomething(foo) \
do \
{ \
int i; \
/* do something with foo and i */ \
} while (0)
--
Grant Edwards grante Yow! I HIJACKED a 747 to
at get here!! I hope those
visi.com fabulous CONEHEADS are
at HOME!!
More information about the Python-list
mailing list