News for hackers. Stuff that matters.
Re:Show HN: Modifying Clang for a Safer, More Explicit C++ by wjko21 on Friday August 19, 2022 @01:58PM (#32524186)
what's the motivation for removing `goto`, is this something that you find being abused? I code in c++ for work, and I almost never see anyone using it without a good reason.
Re:Show HN: Modifying Clang for a Safer, More Explicit C++ by Findecanor on Friday August 19, 2022 @02:58PM (#32524793)
My personal opinion is that a programming language should instead of 'goto', have explicit constructs for those things that 'goto' is most often used to emulate:

• Breaking out of nested loops

• Clause after loop that has run to its end-condition without a break, return or throw. Python allows an 'else'-clause after a loop, but IMHO "default" would be a better keyword.

• Error handling (C++ has exception handling already, but there are alternatives)

Re:Show HN: Modifying Clang for a Safer, More Explicit C++ by compiler-devel on Sunday August 21, 2022 @03:52PM (#32543774)
This is interesting, are there languages in use today with these constructs?
Re:Show HN: Modifying Clang for a Safer, More Explicit C++ by gautamcgoel on Friday August 19, 2022 @05:56PM (#32526450)
Yeah, I'm curious about this as well. I know the Go and Lua creators explicitly included goto in their languages, saying it can be useful if used carefully.
Re:Show HN: Modifying Clang for a Safer, More Explicit C++ by compiler-devel on Sunday August 21, 2022 @03:51PM (#32543768)
> I almost never see anyone using it without a good reason

In any of those cases, could the code have been rewritten without goto?