On Wed, Jun 21, 2000 at 05:03:18PM +0100, Paul Jakma wrote:
> nice. must remember that one. :)
>> am i right in thinking that to do the below without goto would be
> difficult to do legibly?
>> ie goto enhances readibility/structure of this?
int foo()
{
int err;
/* thing 1 setup stuff */
if (thing1()) {
/# thing 2 setup stuff */
if (thing2()) {
/# thing 3 setup stuff */
if (thing3()) {
return SUCCESS;
} else {
fix_thing3();
fix_thing2();
fix_thing1();
err = ERR3;
}
} else {
fix_thing2();
fix_thing1();
err = ERR2;
}
} else {
fix_thing1();
err = ERR1
}
return err;
}
and this is why goto's are used in the kernel. that's ugly, mark's
was nice. particularly with hardware where you have to tweak bits
in small chunks and then check for errors - you could end up stairstepped
into the next screen.
kevin
--
kevin at suberic.net "we were goin' for breakfast. in canada. we
fork()'ed on 37058400 made a deal: if she'd stop hookin', i'd stop
meatspace place: home shootin' people. maybe we were aiming high."
--porter, "payback"
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!