Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #385491

Re: C23 thoughts and opinions

Path csiph.com!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: C23 thoughts and opinions
Date Mon, 03 Jun 2024 16:23:57 -0700
Organization None to speak of
Lines 56
Message-ID <87le3l1ugi.fsf@nosuchdomain.example.com> (permalink)
References <v2l828$18v7f$1@dont-email.me> <v2o57g$1t5p4$1@raubtier-asyl.eternal-september.org> <v3dkgh$2e0me$1@dont-email.me> <v3gou9$36n61$3@dont-email.me> <v3hrq7$1o743$1@news.xmission.com> <v3i7u3$3bp0v$1@dont-email.me> <20240602124448.704@kylheku.com> <v3lgti$325i$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain
Injection-Date Tue, 04 Jun 2024 01:23:57 +0200 (CEST)
Injection-Info dont-email.me; posting-host="90afdb6d92dd2740ec1db4216de117c0"; logging-data="103375"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oi6d+l2Vn8hirsYqng2Ot"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock sha1:IaoUjvLty/+K8LlJMMx6vHLDy/E= sha1:aLuAdF5P5c47ebUKZ4ELepvQdMs=
Xref csiph.com comp.lang.c:385491

Show key headers only | View raw


bart <bc@freeuk.com> writes:
[...]
> At this point someone will suggest a macro this:
>
>   #define forever for(;;)

When I was first learning C, I defined a macro, something like:

    #define ever ;;

so that I could write

    for (ever) {
        /* ... */
    }

At the time, I thought it was very clever.

I still think it was very clever.  But I no longer think that's a
good thing.

> All that suggest sto me is that the language *needs* an explicit
> endless loop!

No, it doesn't.

There are multiple valid and idiomatic ways to write an infinite
loop in C:

    for (;;)
    while (1)
    while (true) // requires C99 or later and #include <stdbool.h>,
                 // or C23 or later without the #include,
                 // or your own "true" macro.

There is nothing wrong with any of them.  All C programmers should
immediately recognize each of them as an infinite loop.  The compiler
might have to do a few different things internally to process each
one -- and that makes no difference to me as a programmer.  If a
compiler generated different code for different forms, I probably
wouldn't notice.  If I bothered to check, I'd be mildly curious
about the reasons, and annoyed if one form was more efficient.

A language designed from the beginning with syntactic and semantic
elegance in mind might have only one explicit form of infinite loop
(though something like "while (true)" or "while (1+1==2)" would
still be allowed).  C is not that language.

I suspect some of the people in this thread saying that one form
is obviously better than the others are joking.

It doesn't matter.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: C23 thoughts and opinions Lynn McGuire <lynnmcguire5@gmail.com> - 2024-05-31 17:55 -0500
  Re: C23 thoughts and opinions David Brown <david.brown@hesbynett.no> - 2024-06-01 15:30 +0200
  Re: C23 thoughts and opinions Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-02 03:29 +0000
    Re: C23 thoughts and opinions Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-01 23:31 -0700
    Re: C23 thoughts and opinions gazelle@shell.xmission.com (Kenny McCormack) - 2024-06-02 13:24 +0000
      Re: C23 thoughts and opinions Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2024-06-02 16:51 +0000
        Re: C23 thoughts and opinions Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-02 19:52 +0000
          Re: C23 thoughts and opinions Michael S <already5chosen@yahoo.com> - 2024-06-03 12:01 +0300
          Re: C23 thoughts and opinions Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-06-03 13:31 -0700
            Re: C23 thoughts and opinions "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-03 14:02 -0700
              Re: C23 thoughts and opinions gazelle@shell.xmission.com (Kenny McCormack) - 2024-06-03 21:48 +0000
                Re: C23 thoughts and opinions David Brown <david.brown@hesbynett.no> - 2024-06-04 10:36 +0200
                Re: C23 thoughts and opinions "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-04 14:47 -0700
          Re: C23 thoughts and opinions bart <bc@freeuk.com> - 2024-06-03 23:43 +0100
            Re: C23 thoughts and opinions Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-03 16:23 -0700
              Re: C23 thoughts and opinions David Brown <david.brown@hesbynett.no> - 2024-06-04 10:47 +0200
            Re: C23 thoughts and opinions Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-04 02:20 +0000
              Re: C23 thoughts and opinions David Brown <david.brown@hesbynett.no> - 2024-06-04 10:47 +0200
            Re: C23 thoughts and opinions Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-04 05:25 +0000
        Re: C23 thoughts and opinions Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-06-03 13:29 -0700

csiph-web