Date: Mon, 6 Jan 2025 13:22:01 +0100
> switch/case is at its core syntactic sugar for a sequence of goto.
> continue and break are syntactic sugar for goto.
So are loops, but I don't see anyone complaining. "while (true)" is
just syntactic sugar for "goto loop_again;", so how come people write
while loops? Are they just performing an utterly pointless exercise
and pretending that computers work differently than they actually do?
Why should languages have while loops at all if we can just use goto
and stop pretending? All control flow structures are really just
syntactic sugar for goto.
Hyperbole aside, just because you can express something using goto,
doesn't mean you should. In fact, you typically shouldn't. Goto is
relatively close to hardware behavior, but so is inline assembly, and
that doesn't mean that you should prefer to write inline assembly over
portable C++ code.
Various modern languages don't come with goto at all; see Rust,
Kotlin, Java, TypeScript, etc. and they are seemingly fine. How come
this 40-year old feature can just not exist in these general-purpose
programming languages, if it's so useful? Maybe it's not so useful.
The proposal isn't trying to get rid of goto anyway. It's only porting
a C feature to C++ which could offer a better (and constexpr)
alternative to some uses of goto.
> There is absolutely no reason why goto cannot be compiled at compile time.
Feel free to make a proposal for constexpr goto. I wouldn't mind.
> continue and break are syntactic sugar for goto.
So are loops, but I don't see anyone complaining. "while (true)" is
just syntactic sugar for "goto loop_again;", so how come people write
while loops? Are they just performing an utterly pointless exercise
and pretending that computers work differently than they actually do?
Why should languages have while loops at all if we can just use goto
and stop pretending? All control flow structures are really just
syntactic sugar for goto.
Hyperbole aside, just because you can express something using goto,
doesn't mean you should. In fact, you typically shouldn't. Goto is
relatively close to hardware behavior, but so is inline assembly, and
that doesn't mean that you should prefer to write inline assembly over
portable C++ code.
Various modern languages don't come with goto at all; see Rust,
Kotlin, Java, TypeScript, etc. and they are seemingly fine. How come
this 40-year old feature can just not exist in these general-purpose
programming languages, if it's so useful? Maybe it's not so useful.
The proposal isn't trying to get rid of goto anyway. It's only porting
a C feature to C++ which could offer a better (and constexpr)
alternative to some uses of goto.
> There is absolutely no reason why goto cannot be compiled at compile time.
Feel free to make a proposal for constexpr goto. I wouldn't mind.
Received on 2025-01-06 12:22:07