[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] stream trouble

From: Alejandro Forero Cuervo
Subject: Re: [Chicken-users] stream trouble
Date: Mon, 3 Oct 2005 14:50:54 -0500
User-agent: Mutt/1.5.10i

> #;1> (require-extension stream-wiki)
> ; loading /usr/lib/chicken/ ...
> ; loading /usr/lib/chicken/ ...
> ; loading /usr/lib/chicken/ ...
> ; loading /usr/lib/chicken/ ...
> ; loading /usr/lib/chicken/ ...
> ; loading /usr/lib/chicken/ ...
> #;2> (define inp (open-input-file 
> "/var/www/localhost/htdocs/wiki/"))
> #;3> (define ins (wiki->html inp))
> #;4> (stream? ins)
> #t
> #;5> (stream->string ins)
> Error: stream library: "attempt to take stream-car of non-stream"

wiki->html expects a stream of characters to operate on, not a port.
You can use port->stream to get a stream with all the characters on a
given port; characters will be read from the port as they are taken
from the string.  Thus, your example could work like this:

#;1> (use stream-wiki)
; ...
#;2> (stream->string (wiki->html (port->stream (open-input-file 
"<p>This is a <a href='test' class='internal'>test</a>.</p>"

BTW, you may be confused by (stream? ins) returning #t in your
example (and the error being caught by stream->string rather than
wiki->html).  This is normal due to the lazy semantics of streams.

Hmm.  I've added a lot of optional parameters to wiki->html to provide
further control to the caller.  Maybe I should document those...



---=(  Comunidad de Usuarios de Software Libre en Colombia  )=---
---=( )=--=( address@hidden  )=---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]