Date: Wed, 3 Jun 1998 11:05:58 +0200 From: Eivind Eklund <eivind@yes.no> To: Terry Lambert <tlambert@primenet.com> Cc: chat@FreeBSD.ORG Subject: Use of gotos (was Re: ppp cannot find libalias) Message-ID: <19980603110558.57456@follo.net> In-Reply-To: <199806022309.QAA23355@usr01.primenet.com>; from Terry Lambert on Tue, Jun 02, 1998 at 11:09:27PM %2B0000 References: <199806021711.KAA01018@antipodes.cdrom.com> <199806022309.QAA23355@usr01.primenet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[moved to -chat] On Tue, Jun 02, 1998 at 11:09:27PM +0000, Terry Lambert wrote: > People who hate goto's for the sake of hating goto's don't understand > that no matter how hard they try, the compiler is going to generate > branch and jump instructions, and there's nothing they can do about it > in a high level language, except cause the optimizer to invoke loop > register preload and unrolling optimizations erroneously. If they can that, then they're not working in a high level language, and they're working with a buggy compiler to boot ;-) > [...] If you see yourself using a lot of goto's, well, it's either > beta code that you've written that way for program flow readability > (don't expect or suggest that it should be checked in) Why not? The only reason I can see not to check in something that is written using gotos _for readability_ is the amount of hysteria it could cause. The (original) argument against gotos is that it obscures readability (that was before it become a religious argument due to too many people parroting what they learnt at college :-) I prefer state machines written using goto's - then I get one state variable to relate to (the position in the program) instead of two. > For non-beta code, where it's now known to work, converting goto's to > negative logic is a win (it saves branch instructions). I'm not certain what you're trying to say here. I can't parse this in any way that makes sense WRT optimizing compilers. (Explaining background, in case I'm missing something) I know of no intermediate code that use _both_ gotos and structured programs. In traditional intermediate codes, the representation use an if/goto-network, and starting in this form have no negative impact - it's what it is made for optimizing :-) This is, IIRC, the representation gcc use. In modern (1990s) compilers, everything is represented as a structured program. This is (again IIRC) to make it easier to move expressions around, and doing many of the advanced optimizations. These are supposed to be able to slide code every which way, to exploit common features. I can't see these being hurt by a goto-based implementation, either. So - what am I missing? Eivind. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980603110558.57456>