Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Programming exercise/challenge Date: Mon, 04 Jan 2021 20:04:16 -0800 Organization: A noiseless patient Spider Lines: 27 Message-ID: <86czykrpvj.fsf@linuxsc.com> References: <86wnxwkyol.fsf@linuxsc.com> <5fcbb652$0$16505$e4fe514c@textnews.kpn.nl> <86a6tvur8x.fsf@linuxsc.com> <20201230104155.77@kylheku.com> <86lfd9syfo.fsf@linuxsc.com> <20210104001549.e79025fef7062a13f4143863@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="80889085611d571f10128e03e1df8783"; logging-data="17743"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hSa51XHW3NJ/CN4x0F2iWlSmadZa8n6g=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:1QiudQEA1Qx/gcATHEbW4kLsXS0= sha1:ggb+bsm6axZpZIoK13bZnH0jzYI= Xref: csiph.com comp.lang.c:158168 Anton Shepelev writes: > Tim Rentsch: > >> Well let's see. Some people say: >> A 'break' statement is just a goto in disguise. >> A 'continue' statement is just a goto in disguise. >> A 'while' (or do/while) is just a goto in disguise. >> A 'for' is just a (syntactically sugared?) goto in disguise. >> A 'switch' is just a (computed?) goto in disguise. >> An 'if' is just a goto in disguise. > > The last four are not goto's in disguise in that they are > control-flow structures of structured programming. I don't think of any of these as gotos in disguise. I know some people do, but I don't. It's like what someone told me once about 'return' - "you can think of it as a function call that pops the stack and sets the PC". I suppose people could think of it that way, but I surely do not. An important characteristic of "goto" is that it can go anywhere (in the same function). None of these constructs have that property. The closest might be 'switch', but even that is limited to the controlled statement of the switch(), and not the whole function.