News for hackers. Stuff that matters.
Re:Boris – A tiny REPL for PHP by amasad on Saturday February 28, 2015 @08:03PM (#9125644)
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

Re:Boris – A tiny REPL for PHP by apinstein on Sunday March 01, 2015 @12:08AM (#9126102)
I 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!
Re:Boris – A tiny REPL for PHP by amasad on Sunday March 01, 2015 @01:53AM (#9126310)
ah interesting, so run the expression in the worker and check the return code? But what if that expression partially ran and had side effects?
Re:Boris – A tiny REPL for PHP by apinstein on Sunday March 01, 2015 @09:01AM (#9127042)
exactly. 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.