<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">Gilbert Martinez wrote at 09/03/2014
12:01 PM:<br>
</div>
<blockquote
cite="mid:CAOyHz4vWHwGqeyJ7PBGXHskGb24dP1O4M0H-WauiSEaDtQ5qpg@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<font face="arial, helvetica, sans-serif">I run the code above
and execute the following in the interactions pane</font><font
face="arial, helvetica, sans-serif">:</font><br>
<blockquote style="margin:0px 0px 0px
40px;border:none;padding:0px">
<div><font face="courier new, monospace">
<div><br>
</div>
<div>Welcome to DrRacket, version
6.1.0.5--2014-08-25(32ae3f8/a) [3m].</div>
<div>Language: racket [custom].</div>
<div>12</div>
<div>>(for ((byte (in-bytes (port->bytes c-in))))</div>
</font>
<div><font face="courier new, monospace"> (printf "~x "
byte))</font></div>
</div>
<div><font face="courier new, monospace"><br>
</font></div>
<div><font face="courier new, monospace"><br>
</font></div>
</blockquote>
<font face="arial, helvetica, sans-serif">The entry above above
hangs on </font><font face="courier new, monospace">port->bytes.</font></div>
</blockquote>
<br>
<font face="courier new, monospace">Unless "in-bytes" is doing more
magic than I feared, I believe that here "port->bytes" is a
procedure that reads all the input to the end-of-file (which won't
happen until the TCP connection is closed), before "in-bytes" or
"for" or anyone else sees anything from the port.<br>
<br>
"port->bytes" is a convenience, mainly for reading files. You
instead probably want to read one byte at a time from the port, or
(a little harder) to do block reads of available bytes from the
port.<br>
<br>
BTW, I think this is another example of how "for" and friends are
confusing to people. I still think that people are better off
first learning how to do things using named-"let" and
mutually-recursive procedures *before* being introduced to "for".
(My biggest objection is that people introduced to "for" first
then end up shoehorning control-flow into "for" even when it
doesn't fit. But I'm saving this new kind of anecdote, about
syntactic sugar obscuring evaluation model, as additional evidence
of "for"'s crimes against humanity.)<br>
<br>
Neil V.<br>
<br>
<br>
</font>
</body>
</html>