🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #238

Re: Taming The Switch-Statement

#238
From: Lawrence D’Oliveiro
Date: Sun, 11 Oct 2026 21:16
15 lines
2198 bytes
On Sun, 11 Oct 2026 05:52:51 -0000 (UTC), Waldek Hebisch wrote:

> AFAICS Pascal-style 'case' + 'goto' that can jump inside constructs
> can do everthing C 'switch' can do.

There is an interesting result known as the “Structure Theorem”, which
proves that any kind of control structure can be implemented by
putting your entire program inside a large switch-statement within a
loop and using state variables to control which path is taken each
time round the loop -- with no gotos anywhere!

Of course, since it can be hard to discern the relationship between
one switch-branch being executed on one loop iteration and whatever
switch-branch is entered on the next iteration, the result is still a
form of spaghetti code ...
Technical Details
Message-ID: <11aguaq$30k5e$4@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <119qf6l$2rmg3$1@dont-email.me> <11ac0mi$19kfd$1@dont-email.me> <11ac2jv$1a84t$1@dont-email.me> <11ac783$1bkuo$1@kst.eternal-september.org> <11ad5eq$1l8hg$1@dont-email.me> <11ad9fg$cjm0$4@dont-email.me> <11addhr$1oakb$1@dont-email.me> <11admri$1s1lb$1@dont-email.me> <11af87h$1m4em$1@paganini.bofh.team>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Sun, 11 Oct 2026 21:16:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <11aguaq$30k5e$4@dont-email.me>
References: <119qf6l$2rmg3$1@dont-email.me> <11ac0mi$19kfd$1@dont-email.me>
	<11ac2jv$1a84t$1@dont-email.me> <11ac783$1bkuo$1@kst.eternal-september.org>
	<11ad5eq$1l8hg$1@dont-email.me> <11ad9fg$cjm0$4@dont-email.me>
	<11addhr$1oakb$1@dont-email.me> <11admri$1s1lb$1@dont-email.me>
	<11af87h$1m4em$1@paganini.bofh.team>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 11 Oct 2026 21:16:11 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3166382"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18pa1l/O/wYd3L475myNRN6"; posting-host="a82cbb4a9e343247fd3ed93594ed57ba"
User-Agent: Pan/0.165 (Kostiantynivka)
Cancel-Lock: sha1:3lKKZmWjKH20rTK8RUoKE/UKGPo= sha256:G5Gt0Csnh/aymP6PrPsryLwD9E5x2alxTucsDqpIPLM=
	sha1:PLaUFY3YK3F7Abao5tBniFu8yf8= sha256:I+rKl6YOg+yGLR7xUjOe0PWzO3NO8FQZpuyGavpsEB4=