Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the REPL accessible via network #47

Closed
steckerhalter opened this issue Aug 7, 2013 · 6 comments
Closed

Make the REPL accessible via network #47

steckerhalter opened this issue Aug 7, 2013 · 6 comments
Labels

Comments

@steckerhalter
Copy link

steckerhalter commented Aug 7, 2013

For example a SWANK backend could be written (http://common-lisp.net/project/slime/).

For reference: a JS SWANK implementation: https://github.com/swank-js/swank-js

Any thoughts?

@d11wtq
Copy link
Contributor

d11wtq commented Aug 7, 2013

Agreed. This is planned. First I need to define a protocol for the communication, then rewrite the readline client to use it. One of the other reasons for defining a protocol is because some things like auto-completion could then be added as protocol extensions. There is some complexity with long-running (and/or concurrent) operations that are producing output which needs to be sent over the network. Currently, because the output is simply sent to stdout, there's no need to handle that sort of thing.

@steckerhalter
Copy link
Author

Cool. I really missed a REPL with PHP. SWANK is an RPC protocol. It would allow easy integration with Emacs for example. But maybe there is another protocol you might want to consider.

@steckerhalter
Copy link
Author

here's another server/client thing for JS that does auto-completion and so on: http://ternjs.net/

@steckerhalter
Copy link
Author

just so that you might be aware of it. there is already an Emacs mode to make the REPL work under Emacs: https://github.com/tomterl/php-boris

I wrote a minor mode that uses that to allow sending parts of a PHP buffer to the REPL in Emacs: https://github.com/steckerhalter/php-boris-minor-mode

It's already close to what you can do with Clojure and nrepl (https://github.com/clojure-emacs/nrepl.el).

So for the networking part... have you thought about the protocol to use?

Btw, there's also https://github.com/tailrecursion/wigwam, but it uses some readline functions that don't work on Debian/Ubuntu PHP. Maybe that can give some inspiration too...

@joddie
Copy link

joddie commented Aug 14, 2013

I did a quick hack to play with this idea and pushed it to https://github.com/joddie/boris/tree/completion-and-network-hacks. It's pretty rough still, but it works well enough for me to get context-aware completion while running Boris under Emacs when the included boris-completion.el is loaded. Completion also sort of works in a terminal, with minor annoyances, if PHP is compiled with GNU readline. It should be smart enough to complete the appropriate normal & static object members and array indexes at any level of nesting, as well as the usual constants/functions/classes/namespaces.

The socket protocol uses JSON messages preceded by 4 bytes giving the length of the data. It would definitely need some extra work to be reliable.

I should emphasise that this was just a hack to experiment with the idea, which may not match @d11wtq's future plans for boris. However, if there is interest in using part or all of it, I'm happy to try refactoring things.

@steckerhalter
Copy link
Author

I have been hacking on a SLIME backend for PHP (https://github.com/steckerhalter/swank-php) and was using what @joddie already added to communicate with the REPL.

Only completion and documentation is available with his extensions so I'll be trying to add evaluation too.

Can someone else look at the code from Joddie too and see if this might be ok to proceed or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants