The following code (derived from simplifying web-repl.scm) _appears_ to work
(define s (open-tcp-server (list server-address: ""
port-number: 12345
eol-encoding: 'cr-lf)))
(define-macro (forever . body)
`(let loop () ,@body (loop)))
(forever
(let ((port1 (read s)))
(set! ##thread-make-repl-channel
(lambda (thread)
(##make-repl-channel-ports port1 port1)))
(##repl-debug-main)))
however, I'm not sure if there's anything (like race conditions) that I've introduced; and clearly we've lost support for important things like control characters; besides that, any other problems? (I like it's sheer readability)
Thanks!
The locking is not needed in web-repl.scm . It is there because the code is left over from an implementation of the telnet protocol where I believe exclusive access to the terminal was needed.
On 21-Jun-09, at 11:14 PM, lowly coder wrote:
Looking at the web-repl.scm file in gambc/examples, I often see situations of:
lock mutex
write single char
flush output
unlock mutex
Why is this necessary? According to the gambit documentation, ports have to be written to handle concurrent read/writes themselves.
Note that the Gambit specs say that *individual calls* to write-char need no locking. But if you want a sequence of calls to write-char to appear uninterrupted, then you need a lock.
Marc