4 ms·
He writes "prepare to cringe" and he is not wrong. As far as I understand, this technique implements GOTO by reading the source code (again) into memory, filter
by ggeorgovassilis 3y ago
He writes "prepare to cringe" and he is not wrong. As far as I understand, this technique implements GOTO by reading the source code (again) into memory, filtering out everything before the target label and evaluating the remaining source code. I think this doesn't preserve state, variables etc. so not really a GOTO. But interesting technique.
edited for clarity
- throwanem 3y ago> I think this doesn't preserve state, variables etc. Why wouldn't it? It's calling eval, not exec.
- DannyBee 3y agoThe more frightening part (at least for me) is the reddit thread that points out this is how windows batch files implement goto, and shows how to see it happen.
- KnobbleMcKnees 3y agoDoes that mean using jumpto to jump to a label above that invocation results in redeclaration of the same code? Seems janky even by the low standards of the author.
- throwanem 3y agoIf that's the scariest thing you know about Windows batch files, you've lived a blameless life.
- DannyBee 3y agoI’m just a babe in the woods