3 ms·
> PHP is the language which would implement a loop by pushing a byte offset to a stack and seek in the file at the end of the loop. I didn't quite understand t
by ReactiveJelly 4y ago
> PHP is the language which would implement a loop by pushing a byte offset to a stack and seek in the file at the end of the loop.
I didn't quite understand this. Is it some famous PHP implementation thing?
- jlouis 4y agoIt's from one of the first implementations of the language. If you want to move fast, and you have no ambition about execution speed, this is a solution to the problem of implementing loops. PHP worked by parsing code directly from the file for every executed statement. So you ran the full lex->parse->interpret path for each statement. A loop need to jump back, which can be tracked by the file offset position, so you can redo the lex->parse->interpret step for the loops statements again. Modern PHP will not do this, because it's highly inefficient. I'm not even sure it survived into the 2000's.