Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Do you insist on const-correctness? Date: Sat, 30 Sep 2023 09:56:47 -0700 Organization: A noiseless patient Spider Lines: 37 Message-ID: <864jjbfvlc.fsf@linuxsc.com> References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc> <86a5tkmj1b.fsf@linuxsc.com> <20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com> <20230923190523.1f810ae96368b345fe455268@gmail.moc> <20230926143726.8fd502c51264c4e127203da4@gmail.moc> <20230926093309.110@kylheku.com> <20230927143445.556@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: dont-email.me; posting-host="a99bceb92abacf1e025e751f28ca3812"; logging-data="1085168"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+qgAXnAj7e/SDcyIyXpfQpcn0n8ou7RAA=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:SsB3wkoV7JOF9lCXKl4De8r3fiQ= sha1:b+1dDOnv1sWnLeK78eELUYFa+Eg= Xref: csiph.com comp.lang.c:176816 Kaz Kylheku <864-117-4973@kylheku.com> writes: [.. combining 'else' with 'for' or 'while', etc ..] > [from some code written in 2011] > > static val lazy_flatten_scan(val list, val *escape) > { > for (;;) { > if (list) { > val a = car(list); > if (nilp(a)) { > list = cdr(list); > } else if (atom(a)) { > return list; > } else do { > push(cdr(list), escape); /* safe mutation: *escape is a local var */ > list = a; > a = car(list); > } while (consp(a)); > return list; > } else if (*escape) { > list = pop(escape); > } else { > return nil; > } > } > } > > I had no idea I've been doing it that long already, and that > a "do" might have started it. [...] This code is truly horrific. Ironically, combining 'do' directly with 'else' may be responsible for a bug in the code.