3 ms·
I have a PHP REPL on repl.it [1] but it's admittedly not that great because certain errors are impossible to recover from, for example a call to an undefined fu
by amasad 12y ago
I have a PHP REPL on repl.it [1] but it's admittedly not that great because certain errors are impossible to recover from, for example a call to an undefined function just kills the process. I don't know how Boris does it but I should just use it.
[1]: http://repl.it/languages/PHP http://repl.it/languages/PHP
- apinstein 12y agoI wrote a PHP repl back in the 5.2 days as I wanted one that could auto-complete, use readline, and survive fatal errors. My solution (really an experiment) was to write all the commands in a temp file and run that file out-of-band. This worked, but caused problems with having to pass global state around, and it didn't allow you to preserve local vars pointing to resources and such. I dug into his code to see how he accomplished this: * EvalWorker is responsible for evaluating PHP expressions in forked processes * Which is a pretty cool setup. The whole thing is nicely architected and I'm looking forward to being able to use it!
- amasad 12y agoah interesting, so run the expression in the worker and check the return code? But what if that expression partially ran and had side effects?
- apinstein 12y agoexactly. side effects were definitely a problem, but it was an experiment and better than losing 20 prior commands! I looked at his source and it's not clear to me how he's also not having the same problem; if the statement is run in a fork then how do you propagate the newly created resources back up to the master? It's impressive though and works well.