Hi,
Lately, I have been playing a bit with 'websocketd'
(github.com/joewalnes/websocketd), a small command-line tool that turns
any application that uses STDIN/STDOUT into a WebSocket server, and I
have discovered that PicoLisp (at least the 32-bit), behaves a little
different from other "applications" (incl. bash and ersatz/pil).
To use 'websocketd' you'll need a browser that supports WebSockets. Take
a look here: <http://caniuse.com/websockets>. I also suggest that you
put websocketd in a place where it can be found by your system with no
need for you to specify its path each time you start it, but that's
elementary stuff.
The easiest way to test websocketd with PicoLisp is to do this:
websocketd --port=8080 -devconsole pil
(You get cleaner results back from PicoLisp if you don't add the "+"
after "pil".)
Now you can direct your browser to <http://localhost:8080/> and click
the connect button to the left of the field that says
"ws://localhost:8080/", and then you can start typing PicoLisp
expressions. Where pil32 (and probably pil64) differs from ersatz/pil
and other "applications", is that if you click the disconnect button,
then pil32 is not terminated. On my Mac it instead starts using close to
100% CPU, and I have to kill it manually. If I, instead of clicking
disconnect, type "(bye)", then PicoLisp terminates and I get a 'disconnect'.
If on the other side I do this:
websocketd --port=8080 -devconsole ./ersatz/pil
.. then clicking disconnect doesn't cause "abnormal" behaviour like
described above.
Something else is that output that goes to STDERR, does not show up in
the browser (it ends up in the websocketd log), and I guess that is why
I don't see any response if I type something like "(foo)", where 'foo'
is undefined. Can output to STDERR in an easy way be redirected to
STDOUT in a REPL script? I have a tiny REPL script (to use instead of
naked pil) that at the moment looks like this:
#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
(load "@lib/misc.l")
(in NIL
(use (Exe Res)
(until (eof)
(setq Exe (read))
(prin "-> ")
(println
(setq Res
(let @ Res
(eval Exe) ) ) )
(flush) ) ) )
Have a Happy New Year!
/Jon
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe