> But it has to allocate the entire string whereas I'd rather "stream"
> the stream out the TCP connection in chunks. So I try this:
>
> <?scheme
> (let ([inp (open-input-file "/var/www/localhost/htdocs/wiki/index.wiki")])
> (require-extension stream-wiki)
> (let loop ([hstr (wiki->html (port->stream inp))])
> (unless (stream-null? hstr)
> (display (stream-car hstr))
> (loop (stream-cdr hstr)))))
> ?>
You can use write-stream, which does exactly this:
<?scheme
(use stream-wiki)
(write-stream (wiki->html (port->stream (open-input-file "somefile"))))
?>
> But if it really sends a character at a time over TCP, it won't be
> very efficient network-wise, and anyway even if it's buffered, maybe
> each call to display is a system call?
I haven't verified whether the output is buffered. I would agree
with you that things would be *extremely* inefficient if it isn't
buffered. If someone confirms it isn't, I suppose we could always
write a write-stream-buffered function that writes things N characters
at a time.
Alejo.
http://azul.freaks-unidos.net/
---=( Comunidad de Usuarios de Software Libre en Colombia )=---
---=( http://bachue.com/colibri )=--=( [EMAIL PROTECTED] )=---
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users