Proposed PEP for a Conditional Expression

Alex Martelli aleax at aleax.it
Fri Sep 14 15:51:36 CEST 2001


"Michael Abbott" <michael at rcp.co.uk> wrote in message
news:Xns911BAEFC8E6DDmichaelrcpcouk at 194.238.50.13...
    ...
> However, I have to admit I can't think of a *useful* statement which
> doesn't contain any semicolons, and the only omission from the statement

I keep proposing my loopalot "metafunction" as having a quite possibly
useful C statement that doesn't contain any semicolons (I posted before
I saw this answer, and it wasn't compliant ISO C in my first post,
as the argument type was missing - I've been Pythoning too much!-):

void loopalot(int (*somefunc)(void)) {
    while(somefunc()) {}
}

Function loopalot calls its function-pointer argument somefunc
one or more times, until the result of one of those calls is 0.
Presumably (*somefunc)() has some side effect as well as
returning 0 (stop looping) or non-0 (keep looping), of course,
but that's up to the caller.


Alex






More information about the Python-list mailing list