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


Groups > comp.lang.c > #402647 > unrolled thread

Taming The Switch-Statement

Started byLawrence D’Oliveiro <ldo@nz.invalid>
First post2026-10-03 08:43 +0000
Last post2026-10-11 22:12 +0000
Articles 20 on this page of 190 — 20 participants

Back to article view | Back to comp.lang.c


Contents

  Taming The Switch-Statement Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-10-03 08:43 +0000
    Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-03 11:24 +0100
      Re: Taming The Switch-Statement Kaz Kylheku <046-301-5902@kylheku.com> - 2026-10-05 22:15 +0000
    Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-03 14:22 +0200
    Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-03 18:02 +0200
      Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-04 00:24 +0800
      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-03 17:36 +0100
        Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-03 16:31 -0700
          Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-04 10:23 +0200
          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-04 12:18 +0100
          Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-04 16:20 +0200
            Re: Taming The Switch-Statement Kaz Kylheku <046-301-5902@kylheku.com> - 2026-10-05 21:34 +0000
              Re: Taming The Switch-Statement "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-10-06 16:04 -0700
        Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-04 16:18 +0200
          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-04 16:09 +0100
            Re: Taming The Switch-Statement scott@slp53.sl.home (Scott Lurndal) - 2026-10-04 16:59 +0000
              Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-04 18:30 +0100
                Re: Taming The Switch-Statement Richard Harnden <richard.nospam@gmail.invalid> - 2026-10-04 19:49 +0100
                  Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-04 20:35 +0100
                    Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-04 22:27 +0200
                      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-04 22:47 +0100
                  Re: Taming The Switch-Statement scott@slp53.sl.home (Scott Lurndal) - 2026-10-04 21:59 +0000
        Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-04 23:38 +0000
          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-05 01:24 +0100
            Re: Taming The Switch-Statement Kaz Kylheku <046-301-5902@kylheku.com> - 2026-10-05 21:48 +0000
              Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-06 00:11 +0100
                Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-06 09:49 +0200
                  Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-06 11:12 +0200
                    Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-06 12:41 +0200
                      Re: Taming The Switch-Statement Richard Harnden <richard.nospam@gmail.invalid> - 2026-10-06 12:33 +0100
                        Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-06 15:16 +0100
                          Re: Taming The Switch-Statement scott@slp53.sl.home (Scott Lurndal) - 2026-10-06 14:37 +0000
                            Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-06 17:27 +0100
                              Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-06 23:14 +0000
                                Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-07 01:25 +0100
                                  Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-07 04:19 +0000
                                    Re: Taming The Switch-Statement Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-10-07 06:28 +0000
                                      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-07 11:39 +0100
                                        Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-07 12:57 +0200
                                    Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-07 11:32 +0100
                                      Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-07 15:10 +0000
                                        Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-07 19:41 +0100
                                          Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-08 04:49 +0000
                                            Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-08 12:24 +0100
                                  Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-07 09:07 +0200
                                    Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-07 11:49 +0100
                                      Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-07 13:11 +0200
                        Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-06 16:17 +0200
                          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-06 15:32 +0100
                            Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-06 17:25 +0200
                          Re: Taming The Switch-Statement scott@slp53.sl.home (Scott Lurndal) - 2026-10-06 14:39 +0000
                            Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-06 19:48 +0200
                              Re: Taming The Switch-Statement scott@slp53.sl.home (Scott Lurndal) - 2026-10-06 18:12 +0000
                                [OT] substances (was Re: Taming The Switch-Statement) Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-06 21:50 +0200
                                Re: Taming The Switch-Statement "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-10-06 17:06 -0700
                      Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-06 19:25 +0200
                        Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-07 10:28 +0200
                          Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-07 15:16 +0200
                            Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-07 16:40 +0200
                            Re: Taming The Switch-Statement Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-10-08 07:24 -0700
                      Re: Taming The Switch-Statement "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-10-06 16:08 -0700
                        Re: Taming The Switch-Statement Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-10-06 23:45 +0000
                          Re: Taming The Switch-Statement "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-10-06 17:08 -0700
                          Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-07 10:35 +0200
                  Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-06 12:33 +0100
                    Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-06 17:16 +0200
                    Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-06 16:41 -0700
                Re: Taming The Switch-Statement tTh <tth@none.invalid> - 2026-10-06 12:14 +0200
                  Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-06 12:43 +0200
                Re: Taming The Switch-Statement Jim Jackson <jj@franjam.org.uk> - 2026-10-06 11:47 +0000
                Re: Taming The Switch-Statement "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-10-06 16:05 -0700
                Re: Taming The Switch-Statement Kaz Kylheku <046-301-5902@kylheku.com> - 2026-10-07 00:42 +0000
                  Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-07 13:52 +0100
                    Re: Taming The Switch-Statement "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-10-07 14:06 -0700
                      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-07 23:31 +0100
        Re: Taming The Switch-Statement Kaz Kylheku <046-301-5902@kylheku.com> - 2026-10-05 21:32 +0000
          Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-06 06:07 +0800
          Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-05 16:42 -0700
            Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-05 18:05 -0700
              Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-06 09:04 +0200
                Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-06 04:11 -0700
                  Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-06 21:40 +0200
              Re: Taming The Switch-Statement Andrey Tarasevich <noone@noone.net> - 2026-10-06 00:59 -0700
                Re: Taming The Switch-Statement Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-10-06 08:16 +0000
                  Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-06 04:21 -0700
            Re: Taming The Switch-Statement scott@slp53.sl.home (Scott Lurndal) - 2026-10-06 14:43 +0000
              Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-06 17:36 +0200
        Re: Taming The Switch-Statement Andrey Tarasevich <noone@noone.net> - 2026-10-06 20:36 -0700
    Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-04 00:20 +0800
    Re: Taming The Switch-Statement Andrey Tarasevich <noone@noone.net> - 2026-10-04 09:05 -0700
      Re: Taming The Switch-Statement Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-10-04 23:44 +0000
        Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-05 01:46 +0100
          Re: Taming The Switch-Statement Andrey Tarasevich <noone@noone.net> - 2026-10-04 20:48 -0700
            Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-05 06:24 +0200
          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-05 11:09 +0100
          Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-06 05:22 +0800
            Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-06 05:26 +0800
    Re: Taming The Switch-Statement Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-10-10 00:25 +0000
      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-10 01:58 +0100
        Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-09 19:17 -0700
          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-10 11:53 +0100
            Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-10 14:01 +0200
              Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-10 14:11 +0100
                Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-10 21:34 +0800
                  Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-10 21:58 +0800
                Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-10 17:50 +0200
                  Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-11 05:52 +0000
                    Re: Taming The Switch-Statement Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-10-11 21:16 +0000
                      Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-11 23:38 +0000
                  Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 11:58 +0100
                    Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-11 14:42 +0200
                      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 14:39 +0100
                        Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-11 15:35 -0700
                    Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-11 14:42 +0000
                      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 17:23 +0100
                        Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-11 17:48 +0000
                          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 19:10 +0100
                            Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-12 07:01 +0000
                    Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 16:41 +0100
                Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-10 20:08 +0200
                  Re: Taming The Switch-Statement Michael S <already5chosen@yahoo.com> - 2026-10-10 22:02 +0300
                    Re: Taming The Switch-Statement cross@spitfire.i.gajendra.net (Dan Cross) - 2026-10-10 19:03 +0000
                      Re: Taming The Switch-Statement Michael S <already5chosen@yahoo.com> - 2026-10-10 22:29 +0300
                    Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-10 21:55 +0200
                      Re: Taming The Switch-Statement Michael S <already5chosen@yahoo.com> - 2026-10-10 23:03 +0300
                        Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-10 22:33 +0200
                          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-10 21:53 +0100
                            Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-10 23:16 +0200
                            Re: Taming The Switch-Statement scott@slp53.sl.home (Scott Lurndal) - 2026-10-11 15:29 +0000
                          Re: Taming The Switch-Statement Andrey Tarasevich <noone@noone.net> - 2026-10-10 15:30 -0700
                            Re: Taming The Switch-Statement Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-10-10 22:58 +0000
                              Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-11 09:09 +0800
                                Re: Taming The Switch-Statement ram@zedat.fu-berlin.de (Stefan Ram) - 2026-10-11 10:14 +0000
                                  Re: Taming The Switch-Statement Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-10-11 21:12 +0000
                            Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-11 03:58 +0200
                          Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-10 15:32 -0700
                            Re: Taming The Switch-Statement Michael S <already5chosen@yahoo.com> - 2026-10-11 01:58 +0300
                              Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 01:43 +0100
                            Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-11 09:12 +0800
                            Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-11 04:07 +0200
                              Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-10 20:13 -0700
                                Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-11 10:36 +0200
                        Re: Taming The Switch-Statement Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-10-11 04:26 -0700
                          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 13:35 +0100
                            Re: Taming The Switch-Statement Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-10-11 06:13 -0700
                              Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 14:51 +0100
                            Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-11 15:33 +0200
                              Re: Taming The Switch-Statement Andrey Tarasevich <noone@noone.net> - 2026-10-11 09:01 -0700
                                Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-11 19:17 +0200
                                  Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 18:57 +0100
                                    Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-11 14:28 -0700
                                      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 23:02 +0100
                                        Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-11 16:29 -0700
                                      Re: Taming The Switch-Statement Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-10-12 04:03 -0700
                                    Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-12 07:05 +0200
                                      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-12 14:37 +0100
                                        Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-12 16:12 +0200
                                          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-12 16:32 +0100
                    Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-10 16:38 -0700
                  Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-10 21:09 +0100
                    Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-10 23:14 +0200
                      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-10 23:01 +0100
                      Re: Taming The Switch-Statement antispam@fricas.org (Waldek Hebisch) - 2026-10-11 08:00 +0000
                        Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-11 10:27 +0200
                          Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-11 10:49 +0200
            Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-10 16:30 -0700
              Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 02:12 +0100
                Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-10 19:55 -0700
                  Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-11 11:00 +0200
                  Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 12:21 +0100
                    Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-11 14:04 -0700
                      Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 23:05 +0100
                        Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-12 07:22 +0200
                          Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-12 11:42 +0100
                            Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-12 16:15 +0200
                            Re: Taming The Switch-Statement scott@slp53.sl.home (Scott Lurndal) - 2026-10-12 14:34 +0000
                              Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-12 16:47 +0100
                                Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-13 00:15 +0800
                Re: Taming The Switch-Statement bart <bc@freeuk.com> - 2026-10-11 22:36 +0100
          Re: Taming The Switch-Statement gazelle@shell.xmission.com (Kenny McCormack) - 2026-10-10 13:14 +0000
          Re: Taming The Switch-Statement Michael S <already5chosen@yahoo.com> - 2026-10-10 19:50 +0300
            Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-10 20:13 +0200
              Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-10 15:54 -0700
                Re: Taming The Switch-Statement Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-10-11 03:41 +0200
                  Re: Taming The Switch-Statement Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-10-11 09:51 +0800
                  Re: Taming The Switch-Statement David Brown <david.brown@hesbynett.no> - 2026-10-11 11:41 +0200
            Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-10 16:44 -0700
          Re: Taming The Switch-Statement Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-10-10 16:56 -0700
      Re: Taming The Switch-Statement Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-10-11 21:26 +0000
        Re: Taming The Switch-Statement Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-10-11 22:12 +0000

Page 9 of 10 — ← Prev page 1 … 7 8 [9] 10  Next page →


#402911

FromJanis Papanagnou <janis_papanagnou+ng@hotmail.com>
Date2026-10-10 23:14 +0200
Message-ID<11ae9r3$cjlv$7@dont-email.me>
In reply to#402899
[ I skip most of what you wrote because it's not adding anything new
   and I basically still just disagree with all you presented; if you
   re-read my previous post you have my comments on your "new" text. ]

On 2026-10-10 22:09, bart wrote:
> On 10/10/2026 19:08, Janis Papanagnou wrote:
>> On 2026-10-10 15:11, bart wrote:
>>> On 10/10/2026 13:01, Janis Papanagnou wrote:
>>>>
>>>> Just imagine if some C-programmers wanted a fall-through semantics
>>>> but all they got would be the Pascal or Algol 68 'case' construct.
>>>
>>> Well, Algol 68 doesn't even have 'break'. For unusual control-flow it 
>>> needs goto.
>>
>> Yes. - And while "C" has 'goto' as well it also supports 'break' for
>> some purposes; e.g. as a loop-exit, so it makes sense to reuse that
>> keyword for other purposes as in 'switch' where it's been useful.
> 
> No, it makes no sense at all, because their use-cases overlap.
> 
> It means that, inside a SWITCH statement, you can't do an early break 
> out of a case-block from inside a loop.
> 
> And if inside a loop, you can't break out of that loop from inside a 
> switch statement:
> 
>     while (1) {
>         if (x == 3)
>             break;
> 
>         switch (x) {
>         case 3: break;
>         }
>     }
> 
> The first break works within IF. But if you choose to use SWITCH, if 
> doesn't work.

It also doesn't work in nested loops. (That's a restriction of C's
'break'.)

I don't think it makes sense to introduce another distinct keyword
to address a special case like that; that's very short-sighted. You
could still not address, e.g., a  "for() for() switch()"  structure.
Other languages provide more universal, thus more sensible features
to support out-of-band conditions, or more universal "local exits"
(that support more than one nested level).

> You still think it makes sense?

Yes, because it works as intended for the other common cases.

If you need a "flexible jump" just use 'goto'. The point of 'break'
is to "tame" that "harmful goto" and introduce something "lighter".

Some languages support a 'break' (and a 'continue') with a numeric
argument to handle the case of nested constructs. That is of course
yet more flexible without sacrificing the "prevent wild jumps" dogma.

[ another big snip ]

>> [*] In the GNU version of Awk - a much simpler but higher abstracted
>> language - you can nicely compare strings, and even regexps.
> 
> I have a narrow view of SWITCH, which is specifically for use with 
> integer values. That allows comparison of N unique possibilities 
> simultaneously, or in O(1) time.
> So if you're comparing strings, then it is not SWITCH IMO, unless those 
> strings are perhaps interned.

A CDC 175/176 carried a Pascal TEXT object in one machine word and
could compare it as atom. Newer standard PC CPUs have more bits in
a word than those former supercomputers. - But the point here was
that internals should be abstracted by a higher level programming
language. - And compilers have principally various possibilities to
support some "atomization" of string comparisons with compile-time
string constants. - As said, it would have been useful in many of
my application cases. (No more, no less.)

(BTW, it would be new to me that you'd have complexity guarantees in
"C".)

Janis

> [...]

[toc] | [prev] | [next] | [standalone]


#402917

Frombart <bc@freeuk.com>
Date2026-10-10 23:01 +0100
Message-ID<11aecjq$24dls$1@dont-email.me>
In reply to#402911
On 10/10/2026 22:14, Janis Papanagnou wrote:
> [ I skip most of what you wrote because it's not adding anything new
>    and I basically still just disagree with all you presented; if you
>    re-read my previous post you have my comments on your "new" text. ]
> 
> On 2026-10-10 22:09, bart wrote:
>> On 10/10/2026 19:08, Janis Papanagnou wrote:
>>> On 2026-10-10 15:11, bart wrote:
>>>> On 10/10/2026 13:01, Janis Papanagnou wrote:
>>>>>
>>>>> Just imagine if some C-programmers wanted a fall-through semantics
>>>>> but all they got would be the Pascal or Algol 68 'case' construct.
>>>>
>>>> Well, Algol 68 doesn't even have 'break'. For unusual control-flow 
>>>> it needs goto.
>>>
>>> Yes. - And while "C" has 'goto' as well it also supports 'break' for
>>> some purposes; e.g. as a loop-exit, so it makes sense to reuse that
>>> keyword for other purposes as in 'switch' where it's been useful.
>>
>> No, it makes no sense at all, because their use-cases overlap.
>>
>> It means that, inside a SWITCH statement, you can't do an early break 
>> out of a case-block from inside a loop.
>>
>> And if inside a loop, you can't break out of that loop from inside a 
>> switch statement:
>>
>>     while (1) {
>>         if (x == 3)
>>             break;
>>
>>         switch (x) {
>>         case 3: break;
>>         }
>>     }
>>
>> The first break works within IF. But if you choose to use SWITCH, if 
>> doesn't work.
> 
> It also doesn't work in nested loops. (That's a restriction of C's
> 'break'.)

That is a separate matter, and one that occurs sparingly.

On the other hand, breaking out of one level is fairly common, and so is 
the use of 'switch'.

Now you have an artificial problem caused by two brain-dead decisions:

* A crappy, crude design of 'switch' that leaves you stranded in the
   middle of the statement

* Deciding to fix that by USING THE SAME KEYWORD as one of the loop
   controls, for something that isn't to do with loops.

This is just very poor language design.

(Inside my C compiler, there are two AST tags called 'jbreak' and 
'jbreaksw' - they are two distinct features.)


> 
> I don't think it makes sense to introduce another distinct keyword
> to address a special case like that; that's very short-sighted. You
> could still not address, e.g., a  "for() for() switch()"  structure.
> Other languages provide more universal, thus more sensible features
> to support out-of-band conditions, or more universal "local exits"
> (that support more than one nested level).

THIS IS NOT A NESTED LOOP PROBLEM! It has been made into one by reusing 
BREAK.

What's the big deal about keywords anyway?


>> You still think it makes sense?
> 
> Yes, because it works as intended for the other common cases.

Would you have made the same choice?

Assuming yes, and assuming you'd also devise some scheme to cut across 
nesting, what would happen here:

    FOR
       SWITCH
          FOR
             SWITCH
                 break...

You want to break out of that inner FOR, but now you have to count both 
nested loops and switch. So, break 2?

So what would break 3 mean: does it get you to the end of that outer 
SWITCH? This is something that would not previously have cross your mind:

    SWITCH
       SWITCH
          break 2

That is, to use 'break' to cut to the end of the enclosing switch 
statements. It is just not meaningful.

This just further shows that the two concepts are distinct.



>> I have a narrow view of SWITCH, which is specifically for use with 
>> integer values. That allows comparison of N unique possibilities 
>> simultaneously, or in O(1) time.
>> So if you're comparing strings, then it is not SWITCH IMO, unless 
>> those strings are perhaps interned.
> 
> A CDC 175/176 carried a Pascal TEXT object in one machine word and
> could compare it as atom. Newer standard PC CPUs have more bits in
> a word than those former supercomputers. - But the point here was
> that internals should be abstracted by a higher level programming
> language. - And compilers have principally various possibilities to
> support some "atomization" of string comparisons with compile-time
> string constants. - As said, it would have been useful in many of
> my application cases. (No more, no less.)

My point is that SWITCH should be a low level feature working on 
integers. (Like how CASE works in Algol68.)

A version for higher level types, for runtime case-values, and a 
possible sequential, ordered search, could share the same keyword, but I 
would prefer a different keywords here since the semantics can be very 
different.

[toc] | [prev] | [next] | [standalone]


#402951

Fromantispam@fricas.org (Waldek Hebisch)
Date2026-10-11 08:00 +0000
Message-ID<11affmm$1m9m7$1@paganini.bofh.team>
In reply to#402911
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> On 2026-10-10 22:09, bart wrote:
>> On 10/10/2026 19:08, Janis Papanagnou wrote:
>>> [*] In the GNU version of Awk - a much simpler but higher abstracted
>>> language - you can nicely compare strings, and even regexps.
>> 
>> I have a narrow view of SWITCH, which is specifically for use with 
>> integer values. That allows comparison of N unique possibilities 
>> simultaneously, or in O(1) time.
>> So if you're comparing strings, then it is not SWITCH IMO, unless those 
>> strings are perhaps interned.
> 
> A CDC 175/176 carried a Pascal TEXT object in one machine word and
> could compare it as atom. Newer standard PC CPUs have more bits in
> a word than those former supercomputers. - But the point here was
> that internals should be abstracted by a higher level programming
> language. - And compilers have principally various possibilities to
> support some "atomization" of string comparisons with compile-time
> string constants. - As said, it would have been useful in many of
> my application cases. (No more, no less.)

In C there are multi-character "characters".  Details are implementation
defined, but AFAICS on 64-bit machine you can pack 8 bytes into single
machine word and use that in a switch.  CDC used 6 bit characters, so
it could cram 10 characters into a single word.  Corresponding comparison
of strings would execute as a single machine instruction.  But AFAIK
Pascal did not allow to use strings in 'case' statement.

In principle C compiler could generate matching code for strings,
basically if all cases correspond to short strings it could pack
characters into a single machine word and then reuse integer
case.  For longer strings it could generate either tree of
comparisons (IIUC some sparse switches use this) or use hashing
to find correct case.  That would be modest extention of current
switch (with sparse case labels one needs to handle most of it
anyway).  I would guess that main counterargument to such a switch
is C++ compatibility: clearly C++ would want such things for classes
and it opens a can of worms.

-- 
                              Waldek Hebisch

[toc] | [prev] | [next] | [standalone]


#402952

FromJanis Papanagnou <janis_papanagnou+ng@hotmail.com>
Date2026-10-11 10:27 +0200
Message-ID<11afh96$286mm$2@dont-email.me>
In reply to#402951
On 2026-10-11 10:00, Waldek Hebisch wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> On 2026-10-10 22:09, bart wrote:
>>> On 10/10/2026 19:08, Janis Papanagnou wrote:
>>>> [*] In the GNU version of Awk - a much simpler but higher abstracted
>>>> language - you can nicely compare strings, and even regexps.
>>>
>>> I have a narrow view of SWITCH, which is specifically for use with
>>> integer values. That allows comparison of N unique possibilities
>>> simultaneously, or in O(1) time.
>>> So if you're comparing strings, then it is not SWITCH IMO, unless those
>>> strings are perhaps interned.
>>
>> A CDC 175/176 carried a Pascal TEXT object in one machine word and
>> could compare it as atom. Newer standard PC CPUs have more bits in
>> a word than those former supercomputers. - But the point here was
>> that internals should be abstracted by a higher level programming
>> language. - And compilers have principally various possibilities to
>> support some "atomization" of string comparisons with compile-time
>> string constants. - As said, it would have been useful in many of
>> my application cases. (No more, no less.)
> 
> In C there are multi-character "characters".  Details are implementation
> defined, but AFAICS on 64-bit machine you can pack 8 bytes into single
> machine word and use that in a switch.  CDC used 6 bit characters, so
> it could cram 10 characters into a single word.  Corresponding comparison
> of strings would execute as a single machine instruction.  But AFAIK
> Pascal did not allow to use strings in 'case' statement.

That is absolutely correct; about the PACKED ARRAY [1..10] OF CHAR
on these CDCs, and about what the Pascal language's CASE allowed
per language definition, which was any enumerable type, and strings
were, being arrays, not enumerable.

I seem to recall that operations on the Pascal's TEXT type were not
very elaborated, though. And assignments were possible for any type
not restricted to primitive types or the TEXT type.

My point was, as you also wrote, that there's possibilities to handle
a short string at least as an atom for comparisons in principle (if
the language definition allows that, if it's appropriately defined).

> 
> In principle C compiler could generate matching code for strings,
> basically if all cases correspond to short strings it could pack
> characters into a single machine word and then reuse integer
> case.  For longer strings it could generate either tree of
> comparisons (IIUC some sparse switches use this) or use hashing
> to find correct case.  That would be modest extention of current
> switch (with sparse case labels one needs to handle most of it
> anyway).  I would guess that main counterargument to such a switch
> is C++ compatibility: clearly C++ would want such things for classes
> and it opens a can of worms.

Yes, probably. - There's so many things you cannot do now, decades
after the base of "C" has been defined.

Janis

[toc] | [prev] | [next] | [standalone]


#402954

FromJanis Papanagnou <janis_papanagnou+ng@hotmail.com>
Date2026-10-11 10:49 +0200
Message-ID<11afiji$286mm$3@dont-email.me>
In reply to#402952
On 2026-10-11 10:27, Janis Papanagnou wrote:
> On 2026-10-11 10:00, Waldek Hebisch wrote:
>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>>> On 2026-10-10 22:09, bart wrote:
>>>> On 10/10/2026 19:08, Janis Papanagnou wrote:
>>>>> [*] In the GNU version of Awk - a much simpler but higher abstracted
>>>>> language - you can nicely compare strings, and even regexps.
>>>>
>>>> I have a narrow view of SWITCH, which is specifically for use with
>>>> integer values. That allows comparison of N unique possibilities
>>>> simultaneously, or in O(1) time.
>>>> So if you're comparing strings, then it is not SWITCH IMO, unless those
>>>> strings are perhaps interned.
>>>
>>> A CDC 175/176 carried a Pascal TEXT object in one machine word and
>>> could compare it as atom. Newer standard PC CPUs have more bits in
>>> a word than those former supercomputers. - But the point here was
>>> that internals should be abstracted by a higher level programming
>>> language. - And compilers have principally various possibilities to
>>> support some "atomization" of string comparisons with compile-time
>>> string constants. - As said, it would have been useful in many of
>>> my application cases. (No more, no less.)
>>
>> In C there are multi-character "characters".  Details are implementation
>> defined, but AFAICS on 64-bit machine you can pack 8 bytes into single
>> machine word and use that in a switch.  CDC used 6 bit characters, so
>> it could cram 10 characters into a single word.  Corresponding comparison
>> of strings would execute as a single machine instruction.  But AFAIK
>> Pascal did not allow to use strings in 'case' statement.
> 
> That is absolutely correct; about the PACKED ARRAY [1..10] OF CHAR
> on these CDCs, and about what the Pascal language's CASE allowed
> per language definition, which was any enumerable type, and strings
> were, being arrays, not enumerable.

I just looked it up in an old book; you could (in Pascal) also
compare "strings" (PACKED ARRAY OF TEXT) by the six comparison
operators (where other general array type objects needed an
element-wise comparison). So you could at least compare strings
of type TEXT directly with IF (and need no function, as in "C").

> 
> I seem to recall that operations on the Pascal's TEXT type were not
> very elaborated, though. And assignments were possible for any type
> not restricted to primitive types or the TEXT type.
> 
> My point was, as you also wrote, that there's possibilities to handle
> a short string at least as an atom for comparisons in principle (if
> the language definition allows that, if it's appropriately defined).
> 
>>
>> In principle C compiler could generate matching code for strings,
>> basically if all cases correspond to short strings it could pack
>> characters into a single machine word and then reuse integer
>> case.  For longer strings it could generate either tree of
>> comparisons (IIUC some sparse switches use this) or use hashing
>> to find correct case.  That would be modest extention of current
>> switch (with sparse case labels one needs to handle most of it
>> anyway).  I would guess that main counterargument to such a switch
>> is C++ compatibility: clearly C++ would want such things for classes
>> and it opens a can of worms.
> 
> Yes, probably. - There's so many things you cannot do now, decades
> after the base of "C" has been defined.
> 
> Janis
> 

[toc] | [prev] | [next] | [standalone]


#402923

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2026-10-10 16:30 -0700
Message-ID<11aehqg$24k8m$3@kst.eternal-september.org>
In reply to#402873
bart <bc@freeuk.com> writes:
> On 10/10/2026 03:17, Keith Thompson wrote:
>> bart <bc@freeuk.com> writes:
>>> On 10/10/2026 01:25, Lawrence D’Oliveiro wrote:
>>>> For comparison, here is an example of Python’s match-statement. Like
>>>> all the good (i.e. non-C-based) designs, the designers saw no point in
>>>> having fall-through.
>>>
>>> C, doesn't specifically have fallthrough. It's just that C's switch is
>>> so bizarre, 'fallthrough' is a consequence of it being so dumb it
>>> doesn't know it's still inside a switch statement; it is just code
>>> that it carries ploughing through until it hits more control flow.
>>
>> C's switch statement is essentially a computed goto.  It goes back
>> to BCPL (1967), which had different syntax (SWITCHON, CASE, ENDCASE)
>> but similar semantics.  BCPL's predecessor, CPL, had a more explicit
>> computed goto that could be used in the same way; the target of a
>> "go to" could be a label expression.
>>
>> Think of C's "switch", not as an inferior version of Pascal's case
>> statement, but as an improved version of a computed goto.
>
> It's not that great as computed goto either. That tended to look like this:
>
>    goto (L1, L2, L3) index

BCPL's "SWITCHON" is a more structured replacement for what was probably
(I'm speculating) a major use case for CPL's "go to expr".

[...]

> And, these days 'computed goto' in C tends to means something
> specific, which is a kind of looping switch but using multiple
> dispatch points (each break has its own goto *jumptable) rather the
> regular switch's one at the start).

Huh?  "computed goto" is not a looping construct.  But C doesn't
have computed goto, so I'm not going to discuss it here other than
in the context of how C's switch statement came to be.

[...]

> (Of, course, my language has it all:

Of course it does.

[...]

>> The ANSI C Rationale says "No serious consideration was given to
>> making the switch more structured, as in Pascal, out of fear of
>> invalidating working code".
>>
>> I suppose some version of C could have defined a new switch-like
>> statement without the fallthrough behavior.  I can see some small
>> advantages in doing so, but the existing switch with fallthrough
>> would have to be kept in the language -- and such a new switch-like
>> statement would have added no real expressive power.  We'd now have
>> a mix of code using the old and new constructs, pressure to convert
>> existing working code, and probably errors introduced by converting
>> code incorrectly.
>
> I guess the same rationale means it is stuck with for(;;) loops?

Yes, of course it does.  Did you think that a construct that's used in
most existing C programs could just be removed from the language?

> That hasn't stop C++ having a higher level version.

C is not C++.  A future C could have additional looping constructs,
but I haven't seen any concrete proposals.

[...]

>> Anything you could do with a more structured switch-like statement can
>> be done, with just a little care, with the existing switch statement.
>
> With a LOT more care, and with too much flexibility making it too easy
> to get things wrong. You even have this:

No, with a little care.

>    case 10: default: case 20:

Doctor, it hurts when I do this.

[...]

>> Yes, you have to remember to write "break;" at the end of each case.
>> I haven't seen any proposals to add such a feature -- probably
>> because nobody else is as angry about it as you are.
>
> I'm angry because it was SO EASY to get right in the first place
> (Algol68 and Pascal already existed), and nearly as easy to fix even
> within the intervening decades.

You're angry about a decision that was made in the 1960s and 1970s,
and you're whining about it to people who can't do anything about it.
That can't be good for you.

I've explained why it doesn't need fixing, and would not be easy to fix.

> It could also be easy to implement as structured switch can be
> syntactic sugar for an if-else-if chain.

If you want an if-else-if chain, write an if-else-if chain.

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

[toc] | [prev] | [next] | [standalone]


#402930

Frombart <bc@freeuk.com>
Date2026-10-11 02:12 +0100
Message-ID<11aenps$27sq7$1@dont-email.me>
In reply to#402923
On 11/10/2026 00:30, Keith Thompson wrote:
> bart <bc@freeuk.com> writes:

> Huh?  "computed goto" is not a looping construct.

You only hear about it in the context of interpreter dispatch loops.

>> (Of, course, my language has it all:
> 
> Of course it does.

Well, it does; what more can I say.
> 
> [...]
> 
>>> The ANSI C Rationale says "No serious consideration was given to
>>> making the switch more structured, as in Pascal, out of fear of
>>> invalidating working code".
>>>
>>> I suppose some version of C could have defined a new switch-like
>>> statement without the fallthrough behavior.  I can see some small
>>> advantages in doing so, but the existing switch with fallthrough
>>> would have to be kept in the language -- and such a new switch-like
>>> statement would have added no real expressive power.  We'd now have
>>> a mix of code using the old and new constructs, pressure to convert
>>> existing working code, and probably errors introduced by converting
>>> code incorrectly.
>>
>> I guess the same rationale means it is stuck with for(;;) loops?
> 
> Yes, of course it does.  Did you think that a construct that's used in
> most existing C programs could just be removed from the language?

I didn't say they should be removed.

>>     case 10: default: case 20:
> 
> Doctor, it hurts when I do this.

It illustrates having too much flexibility. Do compilers check for 
nonsense like this?

Having proper structure must make code analysis simpler than effectively 
having a bunch of case labels randomly scattered through the code.

Example:

    newswitch (expr)
    case 3, 4, 5:
       stmt1;
    case 6...10, 12:
       stmt2;
    else
       stmt3;

I think this is OK except for the possibility of that 'else' being 
attached to stmt2 when that ends with 'if (cond) stmt;'. But C already 
has a rule for that and existing means to get around it.

I haven't put in provision for fall-through. If people want that, then 
old switch will still work.

In this new statement, there is no special meaning for 'break'; it will 
be part of any enclosing old switch or loop.


>> It could also be easy to implement as structured switch can be
>> syntactic sugar for an if-else-if chain.
> 
> If you want an if-else-if chain, write an if-else-if chain.

Then why bother with switch at all?

An implementation HAS to support if-else, so I'm suggesting it wouldn't 
be hard to implement structured switch, since lowering to if-else is one 
easy option.


[toc] | [prev] | [next] | [standalone]


#402937

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2026-10-10 19:55 -0700
Message-ID<11aetqv$29hmu$1@kst.eternal-september.org>
In reply to#402930
bart <bc@freeuk.com> writes:
> On 11/10/2026 00:30, Keith Thompson wrote:
>> bart <bc@freeuk.com> writes:
>
>> Huh?  "computed goto" is not a looping construct.
>
> You only hear about it in the context of interpreter dispatch loops.

I hardly hear about it at all.  I'm aware that it exists as a gcc
extension.  I don't think I've ever used it.  I see no point in
discussing it further.

>> [...]
>> 
>>>> The ANSI C Rationale says "No serious consideration was given to
>>>> making the switch more structured, as in Pascal, out of fear of
>>>> invalidating working code".
>>>>
>>>> I suppose some version of C could have defined a new switch-like
>>>> statement without the fallthrough behavior.  I can see some small
>>>> advantages in doing so, but the existing switch with fallthrough
>>>> would have to be kept in the language -- and such a new switch-like
>>>> statement would have added no real expressive power.  We'd now have
>>>> a mix of code using the old and new constructs, pressure to convert
>>>> existing working code, and probably errors introduced by converting
>>>> code incorrectly.
>>>
>>> I guess the same rationale means it is stuck with for(;;) loops?
>>
>> Yes, of course it does.  Did you think that a construct that's used
>> in most existing C programs could just be removed from the language?
>
> I didn't say they should be removed.

So you want to add a new and less flexible looping construct on top
of the existing one, making the language more complicated with no
real additional expressive power.  (C++'s for loops are a different
matter, sensible because iterators are such a big part of the C++
standard library.)

>>>     case 10: default: case 20:
>>
>> Doctor, it hurts when I do this.
>
> It illustrates having too much flexibility. Do compilers check for
> nonsense like this?

I fundamentally disagree with your claim of "too much flexibility".

"case 10: default: case 20:" perfectly valid, syntactically and
semantically.  It's also silly, and not something someone would
plausibly write other than to make a point.  I see no reason for
compilers to go out of their way to do anything about it.  It's
reasonable for a compiler to warn about plausible errors.  Putting
"default:" in the middle of a set of cases isn't a plausible
error, and I'm fine with the compiler not wasting its time with a
special warning.  (I'd also be fine with a compiler warning about it.)

> Having proper structure must make code analysis simpler than
> effectively having a bunch of case labels randomly scattered through
> the code.

Not really.  A reasonably clever compiler or other tool can easily
recognize a typical switch statement where each sequence of case or
default labels is followed by a "break".  Code analysis becomes a little
more difficult when that pattern is broken by any of several means:
fallthrough, goto, return, continue.

> Example:
[snip]

[...]

>>> It could also be easy to implement as structured switch can be
>>> syntactic sugar for an if-else-if chain.
>>
>> If you want an if-else-if chain, write an if-else-if chain.
>
> Then why bother with switch at all?

It expresses a common pattern.  It can, especially with older compilers,
result in more efficient code (a jump table) that an if/else chain
cannot directly express.  It lets the expression be written and
evaluated just once.  It makes the compiler diagnose the error of
specifying the same value more than once.  It is as expressive as the
more restrictive case statement seen in Pascal and other languages.

It's what we have in the language.  Nobody suggests that it's ideal
or perfect.

Or we could drop every control structure other than "if" and "goto".

> An implementation HAS to support if-else, so I'm suggesting it
> wouldn't be hard to implement structured switch, since lowering to
> if-else is one easy option.

How would your "structured switch" differ from the current switch
statement?  Would the lack of fallthrough be the only difference?
Would the case expressions still have to be constant?  Would you
allow duplicate values?  Would you allow non-integer types, perhaps
with user-defined comparisons?  These are all rhetorical questions,
intended merely to point out that this is not as simple as you seem
to think it is.

Would it add *any* real expressive power to a language that you
hold in contempt anyway?

Sure, we could add every feature that's not too hard to implement.
The end result would be a huge mess.

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

[toc] | [prev] | [next] | [standalone]


#402957

FromJanis Papanagnou <janis_papanagnou+ng@hotmail.com>
Date2026-10-11 11:00 +0200
Message-ID<11afj78$286mm$4@dont-email.me>
In reply to#402937
On 2026-10-11 04:55, Keith Thompson wrote:
> bart <bc@freeuk.com> writes:
>> [...]
> 
> Or we could drop every control structure other than "if" and "goto".

Even 'goto' is redundant if we program in a functional programming way.

*evil grin* ;-)

Janis

> [...]

[toc] | [prev] | [next] | [standalone]


#402974

Frombart <bc@freeuk.com>
Date2026-10-11 12:21 +0100
Message-ID<11afrfq$2j2o6$1@dont-email.me>
In reply to#402937
On 11/10/2026 03:55, Keith Thompson wrote:
> bart <bc@freeuk.com> writes:
>> On 11/10/2026 00:30, Keith Thompson wrote:
>>> bart <bc@freeuk.com> writes:
>>
>>> Huh?  "computed goto" is not a looping construct.
>>
>> You only hear about it in the context of interpreter dispatch loops.

>>> Yes, of course it does.  Did you think that a construct that's used
>>> in most existing C programs could just be removed from the language?
>>
>> I didn't say they should be removed.
> 
> So you want to add a new and less flexible looping construct on top
> of the existing one,

So how would you do it: remove existing switch completely and replace 
with the new version?

Obviously new and old will have to co-exist. This could have been done 
decades ago and the old switch deprecated by now.

> making the language more complicated with no
> real additional expressive power.

It's already getting more complicated.

>> It illustrates having too much flexibility. Do compilers check for
>> nonsense like this?
> 
> I fundamentally disagree with your claim of "too much flexibility".

So what more flexibility do you think switch could have: working across 
functions?
> "case 10: default: case 20:" perfectly valid, syntactically and
> semantically.  It's also silly, and not something someone would
> plausibly write other than to make a point.  I see no reason for
> compilers to go out of their way to do anything about it.

It is nonsense, akin to writing this:

   if (cond) {
      s1;
      else
      s2;
   }

where the else branch is in the middle of the true branch. Is it 
possible that people truly don't realise how utterly bizarre C switch is?

Or if they do, it is astounding that they just shrug it off.


> Not really.  A reasonably clever compiler or other tool can easily
> recognize a typical switch statement where each sequence of case or
> default labels is followed by a "break".  Code analysis becomes a little
> more difficult when that pattern is broken by any of several means:
> fallthrough, goto, return, continue.

See the example in my last post replying to David Brown. What 
control-flow analysis would a compiler make of that?


>> Example:
> [snip]

I see you're not very receptive of it.

> 
> [...]
> 
>>>> It could also be easy to implement as structured switch can be
>>>> syntactic sugar for an if-else-if chain.
>>>
>>> If you want an if-else-if chain, write an if-else-if chain.
>>
>> Then why bother with switch at all?
> 
> It expresses a common pattern.

A common pattern where one of N blocks of code is executed according to 
some control expression.

But that's not what C switch does: it jumps to one of N random labels 
anywhere inside any statement of any complexity and depth.

Those N blocks can overlap. Or after executing one block, it just 
carries on into the next unless stopped via 'break'.

Often one of these N will be an exception (default) but in C that can be 
shared with of the other blocks.

Is this the common pattern you're talking about; total chaos?


> It can, especially with older compilers,
> result in more efficient code (a jump table) that an if/else chain
> cannot directly express.  It lets the expression be written and
> evaluated just once.  It makes the compiler diagnose the error of
> specifying the same value more than once.  It is as expressive as the
> more restrictive case statement seen in Pascal and other languages.

It's an emulation of it but with few guardrails.

> How would your "structured switch" differ from the current switch
> statement?  Would the lack of fallthrough be the only difference?
> Would the case expressions still have to be constant?  Would you
> allow duplicate values?  Would you allow non-integer types, perhaps
> with user-defined comparisons?  These are all rhetorical questions,
> intended merely to point out that this is not as simple as you seem
> to think it is.

Yes it is simple:

* The control expression is an integer
* Case values are constants, and must be unique
* The only comparison is a nominal ==

But it implements that common pattern properly as explained above.

The fall-through question doesn't arise, any more than it does in if-else.

> 
> Would it add *any* real expressive power to a language that you
> hold in contempt anyway?

It provides more safety and more confidence that no weird stuff is going 
on, and confidence that it is properly implementing the common pattern.


> Sure, we could add every feature that's not too hard to implement.
> The end result would be a huge mess.

Then it would be right at home! This is fixing something that should 
long ago have been taken out and shot.

[toc] | [prev] | [next] | [standalone]


#403002

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2026-10-11 14:04 -0700
Message-ID<11agtkb$30q22$1@kst.eternal-september.org>
In reply to#402974
bart <bc@freeuk.com> writes:
> On 11/10/2026 03:55, Keith Thompson wrote:
>> bart <bc@freeuk.com> writes:
>>> On 11/10/2026 00:30, Keith Thompson wrote:
>>>> bart <bc@freeuk.com> writes:
>>>
>>>> Huh?  "computed goto" is not a looping construct.
>>>
>>> You only hear about it in the context of interpreter dispatch loops.
>
>>>> Yes, of course it does.  Did you think that a construct that's used
>>>> in most existing C programs could just be removed from the language?
>>>
>>> I didn't say they should be removed.
>> So you want to add a new and less flexible looping construct on top
>> of the existing one,
>
> So how would you do it: remove existing switch completely and replace
> with the new version?

No, I'd leave it alone.

C's switch statement is, like C as a whole, "quirky, flawed, and
an enormous success" (Dennis Ritchie said that).

You want to add a new construct that differs from switch only in
that it doesn't have implicit fallthrough.  You think the existence
of fallthrough behavior, or of any flexibility that you see as
excessive, is a problem that needs to be fixed.  I don't.

C's switch statement is *almost always* used to implement the same
patterns that can be implemented using Pascal's case statement.
(A minor difference is case ranges, which are proposed for C2y.)

You want to add a "newswitch" construct (presumably with a better
name) that's just like "switch" except that there's no fallthrough.
It would add no real expressive power.  (I'm tempted to propose
calling it "static switch".  To be clear, that's a joke.)

C already has such a construct, called "switch and don't forget to
write break after each case".  There are existing tools that help
with that.

Would it have been better if C's switch statement had behaved
like your "newswitch"?  Yeah, probably.  If I were inventing a new
language, I probably wouldn't copy that particular design decision
from C.  Fallthrough *is* useful sometimes, so I'd probably suggest
adding a "fallthrough" keyword.

But the existing switch statement is good enough, and the cost of
"fixing" it would be much higher than the minimal benefits.

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

[toc] | [prev] | [next] | [standalone]


#403010

Frombart <bc@freeuk.com>
Date2026-10-11 23:05 +0100
Message-ID<11ah16h$320sj$2@dont-email.me>
In reply to#403002
On 11/10/2026 22:04, Keith Thompson wrote:
> bart <bc@freeuk.com> writes:
>> On 11/10/2026 03:55, Keith Thompson wrote:
>>> bart <bc@freeuk.com> writes:
>>>> On 11/10/2026 00:30, Keith Thompson wrote:
>>>>> bart <bc@freeuk.com> writes:
>>>>
>>>>> Huh?  "computed goto" is not a looping construct.
>>>>
>>>> You only hear about it in the context of interpreter dispatch loops.
>>
>>>>> Yes, of course it does.  Did you think that a construct that's used
>>>>> in most existing C programs could just be removed from the language?
>>>>
>>>> I didn't say they should be removed.
>>> So you want to add a new and less flexible looping construct on top
>>> of the existing one,
>>
>> So how would you do it: remove existing switch completely and replace
>> with the new version?
> 
> No, I'd leave it alone.
> 
> C's switch statement is, like C as a whole, "quirky, flawed, and
> an enormous success" (Dennis Ritchie said that).

Yeah, like anyone had a choice in the matter!

> You want to add a new construct that differs from switch only in
> that it doesn't have implicit fallthrough.  You think the existence
> of fallthrough behavior, or of any flexibility that you see as
> excessive, is a problem that needs to be fixed.  I don't.

So you don't really get it. That's fine.

[toc] | [prev] | [next] | [standalone]


#403026

FromDavid Brown <david.brown@hesbynett.no>
Date2026-10-12 07:22 +0200
Message-ID<11ahqpu$38ir0$3@dont-email.me>
In reply to#403010
On 12/10/2026 00:05, bart wrote:
> On 11/10/2026 22:04, Keith Thompson wrote:
>> bart <bc@freeuk.com> writes:
>>> On 11/10/2026 03:55, Keith Thompson wrote:
>>>> bart <bc@freeuk.com> writes:
>>>>> On 11/10/2026 00:30, Keith Thompson wrote:
>>>>>> bart <bc@freeuk.com> writes:
>>>>>
>>>>>> Huh?  "computed goto" is not a looping construct.
>>>>>
>>>>> You only hear about it in the context of interpreter dispatch loops.
>>>
>>>>>> Yes, of course it does.  Did you think that a construct that's used
>>>>>> in most existing C programs could just be removed from the language?
>>>>>
>>>>> I didn't say they should be removed.
>>>> So you want to add a new and less flexible looping construct on top
>>>> of the existing one,
>>>
>>> So how would you do it: remove existing switch completely and replace
>>> with the new version?
>>
>> No, I'd leave it alone.
>>
>> C's switch statement is, like C as a whole, "quirky, flawed, and
>> an enormous success" (Dennis Ritchie said that).
> 
> Yeah, like anyone had a choice in the matter!

There are /no/ programming languages that are successful, but not 
"quirky and flawed" - though there will always be differing opinions on 
what aspects are "quirky", and what aspects are "flawed".  As long as 
there is more than one person involved, writing code in more than one 
way for more than one task, this is inevitable.

The conflicts you have with people here do not stem from the quirks or 
flaws that you see in the C language.  They stem from your totally 
unjustified belief that others do not see C as quirky and flawed - your 
arrogant and megalomanic belief that you alone see its quirks and flaws, 
and that you alone can "fix" them.

The rest of us know that C is a very successful language, and can use it 
to write good and useful code.  Some people here write in C because they 
like the language, some because it is the only language they can use 
(for one of many possible reasons).  I have never met a C programmer who 
does not think the language would have been better with certain changes 
- but I have never met a programmer of /any/ language who does not have 
ideas about how the language could have been better for their use.

> 
>> You want to add a new construct that differs from switch only in
>> that it doesn't have implicit fallthrough.  You think the existence
>> of fallthrough behavior, or of any flexibility that you see as
>> excessive, is a problem that needs to be fixed.  I don't.
> 
> So you don't really get it. That's fine.
> 

So now you can drop it, along with all your other complaints about the C 
language and tools people use with it?

Alternatively, you are free to write proposals for the C standards 
committee, or take part in their discussions, aiming to actually change 
the things you so passionately insist need fixing.



[toc] | [prev] | [next] | [standalone]


#403029

Frombart <bc@freeuk.com>
Date2026-10-12 11:42 +0100
Message-ID<11aidi3$3gbu4$1@dont-email.me>
In reply to#403026
On 12/10/2026 06:22, David Brown wrote:
> On 12/10/2026 00:05, bart wrote:

>> So you don't really get it. That's fine.
>>
> 
> So now you can drop it, along with all your other complaints about the C 
> language and tools people use with it?

My opinions haven't changed at all. KT doesn't care because he doesn't 
understand the importance of having properly designed features. Probably 
he hasn't been involved in having to process somebody else's source code 
or having to translate it or port it.

I have an old tool which /visualises/ C source code by trying to express 
it in my syntax. It is not a formal transpiler: the semantics are not 
translated, just the shape of the code.

Still, the transformation is usually startlingly clear compared with the 
original. Anyway I applied it to two examples, first:

     switch (a) {
     case 1: 10; break;
     case 2: 20; break;
     default: 30;
     }

The output is:

     switch a
     when 1 then
         10
     when 2 then
         20
     else
         30
     end

Notice there are no breaks (which don't exist in my syntax). This is the 
second:

     switch (a) {
     default:
         if (b) {
             case 1: 10; break;
             case 2: 20; break;
         }
     }

The ") {" had to present as the tool requires the switch body to be a 
compound statement. The output is:

     switch a
     else
         if b then

         end
     end

This generated error messages about case-statement not being supported 
(being out of place).

But it doesn't look right does it?. Maybe a better version could express 
switch using gotos and arrays of label-pointers, but this would be 
disastrous for examples like the first.

I then tried Duff's example for fun, and it produced this:

     switch count rem 8
     when 0 then
         to^ := (from++)^
         fallthrough
     when 7 then
         to^ := (from++)^
         fallthrough
     when 6 then
         to^ := (from++)^
         fallthrough
     when 5 then
         to^ := (from++)^
         fallthrough
     when 4 then
         to^ := (from++)^
         fallthrough
     when 3 then
         to^ := (from++)^
         fallthrough
     when 2 then
         to^ := (from++)^
         fallthrough
     when 1 then
         to^ := (from++)^
     end

I'm surprised that it detected fall-through, but probably only in the 
simplest cases (non-empty block not ending in 'break').

'fallthrough' doesn't exist in my syntax so here it must just be a hint.


> Alternatively, you are free to write proposals for the C standards 
> committee, or take part in their discussions, aiming to actually change 
> the things you so passionately insist need fixing.
I'll be long dead before anything happens. It's taken most of my 
lifetime before even a no-brainer like binary literals became official.

[toc] | [prev] | [next] | [standalone]


#403034

FromDavid Brown <david.brown@hesbynett.no>
Date2026-10-12 16:15 +0200
Message-ID<11aiq1l$3kr94$2@dont-email.me>
In reply to#403029
On 12/10/2026 12:42, bart wrote:
> On 12/10/2026 06:22, David Brown wrote:
>> On 12/10/2026 00:05, bart wrote:
> 
>>> So you don't really get it. That's fine.
>>>
>>
>> So now you can drop it, along with all your other complaints about the 
>> C language and tools people use with it?
> 
> My opinions haven't changed at all. KT doesn't care because he doesn't 
> understand the importance of having properly designed features. Probably 
> he hasn't been involved in having to process somebody else's source code 
> or having to translate it or port it.
> 

Again, I am not responsible for other people's posts - but I am entirely 
confident that Keith appreciates well-designed programming languages. 
And I am entirely confident that he was a lot of experience dealing with 
other people's code.

> 
>> Alternatively, you are free to write proposals for the C standards 
>> committee, or take part in their discussions, aiming to actually 
>> change the things you so passionately insist need fixing.
> I'll be long dead before anything happens. It's taken most of my 
> lifetime before even a no-brainer like binary literals became official.

That is perhaps because the people involved with the C language not only 
/have/ brains, but they also use them.

[toc] | [prev] | [next] | [standalone]


#403035

Fromscott@slp53.sl.home (Scott Lurndal)
Date2026-10-12 14:34 +0000
Message-ID<td6zS.60653$jNL6.31326@fx12.iad>
In reply to#403029
bart <bc@freeuk.com> writes:
>On 12/10/2026 06:22, David Brown wrote:
>> On 12/10/2026 00:05, bart wrote:
>
>>> So you don't really get it. That's fine.
>>>
>> 
>> So now you can drop it, along with all your other complaints about the C 
>> language and tools people use with it?
>
>My opinions haven't changed at all. KT doesn't care because he doesn't 
>understand the importance of having properly designed features.

"properly designed" by what criteria?

Making you happy is not a valid criteria.

[toc] | [prev] | [next] | [standalone]


#403038

Frombart <bc@freeuk.com>
Date2026-10-12 16:47 +0100
Message-ID<11aivdn$3nvmh$1@dont-email.me>
In reply to#403035
On 12/10/2026 15:34, Scott Lurndal wrote:
> bart <bc@freeuk.com> writes:
>> On 12/10/2026 06:22, David Brown wrote:
>>> On 12/10/2026 00:05, bart wrote:
>>
>>>> So you don't really get it. That's fine.
>>>>
>>>
>>> So now you can drop it, along with all your other complaints about the C
>>> language and tools people use with it?
>>
>> My opinions haven't changed at all. KT doesn't care because he doesn't
>> understand the importance of having properly designed features.
> 
> "properly designed" by what criteria?
> 
> Making you happy is not a valid criteria.

Is there any language that you would consider badly designed?

If so, what would you do if it become amazingly popular and you were 
obliged to deal with it in your work; would you change your mind, or 
would you still think it was poor?

Hopefully the latter.

But back to C: this is how 'switch' is defined in the grammar:

   'switch' ( expression ) statement

Notice no mention of 'case' or 'default' statements!

Is that not a giant red flag, that there is normal shape to 
switch-statement syntax?

[toc] | [prev] | [next] | [standalone]


#403039

FromJohann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid>
Date2026-10-13 00:15 +0800
Message-ID<dI7zS.10223$AEj4.10181@fx17.ams4>
In reply to#403038
On 10/12/2026 11:47 PM, bart wrote:
> On 12/10/2026 15:34, Scott Lurndal wrote:
>> bart <bc@freeuk.com> writes:
>>> On 12/10/2026 06:22, David Brown wrote:
>>>> On 12/10/2026 00:05, bart wrote:
>>>
>>>>> So you don't really get it. That's fine.
>>>>>
>>>>
>>>> So now you can drop it, along with all your other complaints about 
>>>> the C
>>>> language and tools people use with it?
>>>
>>> My opinions haven't changed at all. KT doesn't care because he doesn't
>>> understand the importance of having properly designed features.
>>
>> "properly designed" by what criteria?
>>
>> Making you happy is not a valid criteria.
> 
> Is there any language that you would consider badly designed?
> 
> If so, what would you do if it become amazingly popular and you were 
> obliged to deal with it in your work; would you change your mind, or 
> would you still think it was poor?
> 
> Hopefully the latter.
> 
> But back to C: this is how 'switch' is defined in the grammar:
> 
>    'switch' ( expression ) statement
> 
> Notice no mention of 'case' or 'default' statements!
> 
> Is that not a giant red flag, that there is normal shape to switch- 
> statement syntax?

Not to me.  A giant red flag would be something akin to

   switch ( foo ) printf( "Hello, bart\n" ) ;

where the printf() never gets called.


Best wishes, and happy red flags!
-- 
Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | via Easynews.com
https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
Federated at https://fed.brid.gy/bsky/myrkraverk.bsky.social

[toc] | [prev] | [next] | [standalone]


#403008

Frombart <bc@freeuk.com>
Date2026-10-11 22:36 +0100
Message-ID<11agvhl$31ftr$1@dont-email.me>
In reply to#402930
On 11/10/2026 02:12, bart wrote:

> Having proper structure must make code analysis simpler than effectively 
> having a bunch of case labels randomly scattered through the code.
> 
> Example:
> 
>     newswitch (expr)
>     case 3, 4, 5:
>        stmt1;
>     case 6...10, 12:
>        stmt2;
>     else
>        stmt3;
> 
> I think this is OK except for the possibility of that 'else' being 
> attached to stmt2 when that ends with 'if (cond) stmt;'.

It might have more problems than that, due to not having 'closure'. That 
is, delimiting that might be done by 'end' or via indents in some 
languages, or by '}' here.

I would prefer not to have enclose the whole body in braces. But as it 
is, then here:

      newswitch()
      case          // 1
          newswitch()
          case
          case      // 3
      case          // 4

it's not clear, when there is no 'else' part, whether case(4) continues 
that second switch and from case(3) or the first and case(1), and there 
is no way to disambiguate.

OK, not a big problem, it's not hard to fix. Fortunately I'm not going 
to implement it.

(BTW I had a look at an old versions of my language, and it seems it 
didn't acquire 'switch' until quite late.

Instead there was another, more flexible statement:

* This worked for scalar types ints, floats and pointers

* Test values could be runtime expressions

* Comparisons were done sequentially

* The whole thing could return a value and be used in expressions, or
   be the last statement of a value-returning function.

I believe 'switch' was introduced as an explicit streamlined version with:

* Only 'int' expressions

* Test values had to be compile-time constants

* Comparisons were expected to be done in parallel, and via
   a jump-table.

Having two forms was considered simpler than the compiler trying to 
analyse the one kind of statement, and silently /not/ using a jumptable 
due to some oversight.)

[toc] | [prev] | [next] | [standalone]


#402876

Fromgazelle@shell.xmission.com (Kenny McCormack)
Date2026-10-10 13:14 +0000
Message-ID<11addmq$3k6om$1@news.xmission.com>
In reply to#402868
In article <11ac783$1bkuo$1@kst.eternal-september.org>,
Keith Thompson  <Keith.S.Thompson+u@gmail.com> wrote:
...
>The ANSI C Rationale says "No serious consideration was given to
>making the switch more structured, as in Pascal, out of fear of
>invalidating working code".
>
>I suppose some version of C could have defined a new switch-like
>statement without the fallthrough behavior.  I can see some small
>advantages in doing so, but the existing switch with fallthrough
>would have to be kept in the language -- and such a new switch-like
>statement would have added no real expressive power.  We'd now have
>a mix of code using the old and new constructs, pressure to convert
>existing working code, and probably errors introduced by converting
>code incorrectly.

You are probably right that C itself will never have such a construct
added (*).  But the point is that there are many C-derived languages -
languages that use C's basic syntax (especially, using curly braces).
C++/C#/Swift - probably others.

These languages are free to have (and probably do) have better
switch/case/whatever-you-want-to-call-it constructs.

(*) Although I certainly think it would benefit from doing so.
-- 
   To be evangelical is to spend every waking moment hovering around
   two emotional states: fear and rage. Evangelicals are seriously the
   angriest and most vicious bunch of self-pitying, constantly-moaning
   whinybutts I've ever encountered.

[toc] | [prev] | [next] | [standalone]


Page 9 of 10 — ← Prev page 1 … 7 8 [9] 10  Next page →

Back to top | Article view | comp.lang.c


csiph-web