Trying something new. ITT we debate the merits of different programming languages without the autism. We're all adults here, or at least most of you pretend to be to avoid being banned. Let's have a proper technical discussion on programming languages.
The two rules are: -No ad-hominems allowed. As a participant in the thread, you are free and encouraged to ridicule anyone who does this, as long as it is on the basis of their behavior rather than their opinion. -All arguments must be technical. Shitting on a language's userbase is underage behavior. So are pajeet/onions memes. Examples of underage behavior: >ENTERPRISE POO LANGUAGE >RUST SJW S O Y LANG >FORTH IS THE WHITE MAN'S LANGUAGE >Everyone who doesn't use C is a nigger
SSA for most things as CPS-compiled code tends to make lots of non local jumps and fuck up your cache.
CPS but reducing all the administrative redexes (aka ANF) is ok, but better left to functional languages where the presence of call operators requires it.
Levi Brooks
Anyone has a tips for implementing error recovery in recursive descent parser? Approach to check every parser nesting function call's return value and either throw the error up or try to synchronize isn't ideal. Programming it in language with exceptions might be suggested, but it just cleans this cancellation problem and not an overall design.
Examples that I don't have properly solved: parser is in states: top level->function->statement->expression And encounters invalid expression. synchronization point could be semicolon at the end of each statement or significant keyword starting other statement. But parser encounters e.g. FUNCTION keyword which only introduces top level statement. Should the parser attempt to synchronize on that to top-level statement or just bail completely? Any nice simple implementations of parser with synchronization? Possibly in lang without exceptions? Maybe I will give up on that and bail on first parser error. That shit is so by miles simpler.
Aaron Hall
I don't bother with error recovery. I abort with the message "syntax error."
Josiah Peterson
Yeah that's so freaking easy. Currently also print the whole line in question, which is an ok usability for me. But anything I've managed to come up with just wan't elegant, I wondered if there is some existing solutions that look nice. Both Wirth and Engineering a Compiler mention error recovery but none describe how to actually implement it, only that such possibility exists.
Sebastian Allen
One approach I see a lot is to just discard tokens until you find something you expect. Another is to replace what you found with what you expected, if they look similar enough (eg. comma/semicolon). Another, if there are very few possibilities, is to insert the token you expected. Obviously you need the appropriate support built into your tokenizer API.