'while/else' (ugh) (was Re: [oclug] Ruby)
willy at debian.org
Fri Jun 27 16:37:04 EDT 2003
On Fri, Jun 27, 2003 at 04:27:30PM -0400, Patrick Smith wrote:
> OK, that makes sense. I presume you also intend for the finally clause
> to be executed even if the while is exited by a break. So it replaces:
> cleanup_needed = false
> while condition
> side effects
> cleanup_needed = true
> if cleanup_needed
> Personally, I suspect this wouldn't be used often enough to justify
> adding another construct to the language, given that it is so easy to do
Not only that, you often want the variable outside the loop anyway. To
take the freeing memory example ...
ptr = malloc(1MB);
} while (condition);
i'm really not sure how much there is to cleanup if you didn't have to
setup before the first loop iteration. anyone got a real example?
"It's not Hollywood. War is real, war is primarily not about defeat or
victory, it is about death. I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk
More information about the OCLUG