The following code (derived from simplifying web-repl.scm) _appears_ to work<br><br>(define s (open-tcp-server (list server-address: ""<br>                                 port-number: 12345<br>                                 eol-encoding: 'cr-lf)))<br>
<br>(define-macro (forever . body)<br>  `(let loop () ,@body (loop)))<br><br>(forever<br>  (let ((port1 (read s)))<br>    (set! ##thread-make-repl-channel<br>          (lambda (thread)<br>            (##make-repl-channel-ports port1 port1)))<br>
    (##repl-debug-main)))<br><br><br>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)<br>
<br>Thanks!<br><br><div class="gmail_quote">On Mon, Jun 22, 2009 at 6:36 AM, Marc Feeley <span dir="ltr"><<a href="mailto:feeley@iro.umontreal.ca">feeley@iro.umontreal.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5"><br>
On 21-Jun-09, at 11:14 PM, lowly coder wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Looking at the web-repl.scm file in gambc/examples, I often see situations of:<br>
<br>
lock mutex<br>
write single char<br>
flush output<br>
unlock mutex<br>
<br>
Why is this necessary? According to the gambit documentation, ports have to be written to handle concurrent read/writes themselves.<br>
</blockquote>
<br></div></div>
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.<br>
<br>
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.<br><font color="#888888">
<br>
Marc<br>
<br>
</font></blockquote></div><br>