News for hackers. Stuff that matters.
Re:Show HN: ShivyC – Hobby C compiler created in Python by JasonFruit on Friday March 30, 2018 @10:48PM (#16721391)
That's not an uncommon practice in Python based on its (relatively) fast handling of exceptions. Maybe you could call it "break things and move fast."
Re:Show HN: ShivyC – Hobby C compiler created in Python by lou1306 on Saturday March 31, 2018 @05:21AM (#16722517)
Using exceptions is totally common, but this seems to raise/catch/log 6 errors each time it tries to parse a `for` statement. I'm a noob when it comes to compilers, but maybe a token -> function dictionary would be a better approach?
Re:Show HN: ShivyC – Hobby C compiler created in Python by JasonFruit on Saturday March 31, 2018 @07:58AM (#16722922)
That does sound a bit extreme. (I freely admit I went by this description and never looked at the parser code myself, though some other portions I did read were pretty normal Python.)
Re:Show HN: ShivyC – Hobby C compiler created in Python by dangerbird2 on Saturday March 31, 2018 @11:51AM (#16723759)
Python implements iterators by raising a GeneratorExit, StopIteration or StopAsyncIteration exception. Exception handling is one of the core means of control flow in python along with function calls and if statements.

Also, because python lacks gotos and switch statements, "exception-oriented" code is a good way to implement efficient finite state machines common in compiler code.