Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.misc > #11889
| From | ram@zedat.fu-berlin.de (Stefan Ram) |
|---|---|
| Newsgroups | comp.lang.misc, comp.lang.c++ |
| Subject | Why no string switch? (was: Resources to learn common lisp?) |
| Followup-To | comp.lang.c++ |
| Date | 2026-09-19 12:46 +0000 |
| Organization | Stefan Ram |
| Message-ID | <inspect-20260919134354@ram.dialup.fu-berlin.de> (permalink) |
| References | (22 earlier) <expressiveness-20260827111602@ram.dialup.fu-berlin.de> <expressiveness-20260827113139@ram.dialup.fu-berlin.de> <gU1rS.86252$Pq3.1276@fx14.ams4> <118jkaj$1d9vr$1@dont-email.me> <expected-20260918162315@ram.dialup.fu-berlin.de> |
Cross-posted to 2 groups.
Followups directed to: comp.lang.c++
ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
>inspect (mystr) {
> "hello" => { /* ... */ },
Why there is no string "switch" statement in C++
C++ is a systems programming language with zero-cost abstraction.
The core language consists of predictable, low-level primitives
(like "if", "while", "switch", or "+") that map to basic machine
instructions and require minimal runtime overhead.
If a native C++ inspect statement allowed matching a string variable
against string cases, a single "primitive-looking" statement would
actually execute an O(N) string-comparison loop at runtime. Depending
on how the compiler tries to optimize it, it might generate a sequen-
tial chain of string comparisons, a trie structure, or a hashing rou-
tine.
Introducing a feature into the core language grammar that can intro-
spect, match, and switch on complex string types blurs the historical
boundary between lightweight primitive instructions in the core lan-
guage and complex library types, making it more difficult for program-
mers to "see" the run-time costs of core language features.
Newsgroups: comp.lang.misc,comp.lang.c++
Followup-To: comp.lang.c++
Back to comp.lang.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-24 19:38 +0800
Re: Resources to learn common lisp? tfb <tfb@work.it.out> - 2026-08-24 12:22 +0000
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-24 21:04 +0800
Re: Resources to learn common lisp? tfb <tfb@work.it.out> - 2026-08-24 13:18 +0000
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-24 22:16 +0800
Re: Resources to learn common lisp? tfb <tfb@work.it.out> - 2026-08-24 20:10 +0000
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-25 10:34 +0800
Re: Resources to learn common lisp? Paul Rubin <no.email@nospam.invalid> - 2026-08-24 17:10 -0700
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-08-25 10:41 +0800
Re: Resources to learn common lisp? tfb <tfb@work.it.out> - 2026-08-25 09:22 +0000
Re: Resources to learn common lisp? Paul Rubin <no.email@nospam.invalid> - 2026-08-25 22:13 -0700
Re: Resources to learn common lisp? Anton Antimo <anton@safunu.org> - 2026-08-26 15:43 -0300
Re: Resources to learn common lisp? Paul Rubin <no.email@nospam.invalid> - 2026-08-26 18:23 -0700
Re: Resources to learn common lisp? Anton Antimo <anton@safunu.org> - 2026-08-28 17:29 -0300
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-08-27 10:17 +0000
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-08-27 10:47 +0000
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-18 10:49 +0800
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 10:25 +0000
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-18 11:05 +0800
Re: Resources to learn common lisp? red floyd <no.spam.here@its.invalid> - 2026-09-17 21:43 -0700
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 10:28 +0000
Re: Resources to learn common lisp? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-09-18 21:33 +0800
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 13:51 +0000
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 14:23 +0000
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 15:18 +0000
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-19 00:07 +0800
Resources to learn Japanese (was: Resources to learn common lisp?) ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 16:52 +0000
Re: Resources to learn common lisp? boltar@caprica.universe - 2026-09-18 15:11 +0000
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 15:25 +0000
Re: Resources to learn common lisp? boltar@caprica.universe - 2026-09-18 15:49 +0000
Re: Resources to learn common lisp? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-18 16:05 +0000
Re: Resources to learn common lisp? boltar@caprica.universe - 2026-09-19 08:29 +0000
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-19 16:50 +0800
Re: Resources to learn common lisp? David Brown <david.brown@hesbynett.no> - 2026-09-18 18:18 +0200
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-19 00:35 +0800
Why no string switch? (was: Resources to learn common lisp?) ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-19 12:46 +0000
Re: Why no string switch? (was: Resources to learn common lisp?) boltar@caprica.universe - 2026-09-19 14:47 +0000
Re: Resources to learn common lisp? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-18 23:39 +0800
csiph-web