Email list hosting service & mailing list manager

Quick question about SRFI-170 directory-files hga@xxxxxx (29 Jul 2019 15:46 UTC)
(missing)
(missing)
Re: Quick question about SRFI-170 directory-files hga@xxxxxx (29 Jul 2019 17:08 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 17:42 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 17:51 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:02 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:15 UTC)
Put directory-fold in the SRFI? hga@xxxxxx (29 Jul 2019 18:45 UTC)
Re: Put directory-fold in the SRFI? John Cowan (29 Jul 2019 19:38 UTC)
Re: Quick question about SRFI-170 directory-files John Cowan (29 Jul 2019 20:26 UTC)
Re: Quick question about SRFI-170 directory-files Marc Feeley (29 Jul 2019 18:28 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:31 UTC)
Re: Quick question about SRFI-170 directory-files Marc Feeley (29 Jul 2019 18:46 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:57 UTC)
Re: Quick question about SRFI-170 directory-files Marc Feeley (29 Jul 2019 19:04 UTC)
Re: Quick question about SRFI-170 directory-files hga@xxxxxx (29 Jul 2019 18:32 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:51 UTC)
Re: Quick question about SRFI-170 directory-files hga@xxxxxx (29 Jul 2019 19:16 UTC)
Re: Quick question about SRFI-170 directory-files John Cowan (30 Jul 2019 18:52 UTC)
Re: Quick question about SRFI-170 directory-files hga@xxxxxx (30 Jul 2019 19:58 UTC)
Re: Quick question about SRFI-170 directory-files John Cowan (30 Jul 2019 20:44 UTC)
(missing)
make-directory-files-generator hga@xxxxxx (06 Sep 2019 16:21 UTC)
Re: make-directory-files-generator hga@xxxxxx (06 Sep 2019 17:24 UTC)
(missing)
Re: make-directory-files-generator hga@xxxxxx (06 Sep 2019 21:56 UTC)
Re: Quick question about SRFI-170 directory-files Lassi Kortela (29 Jul 2019 18:06 UTC)

Re: Quick question about SRFI-170 directory-files Marc Feeley 29 Jul 2019 18:46 UTC

Marc

> On Jul 29, 2019, at 2:31 PM, Lassi Kortela <xxxxxx@lassi.io> wrote:
>
> That's cool. So you read it with 'read' like a Scheme port and it returns strings.
>
> A portable way to do the same nowadays might be SRFI 158 generators:
>
> (directory-generator "examples")

Gambit unifies such generators using ports.  For example, another interesting one are FIFOs:

> (define fifo (open-vector))
> (write 111 fifo)
> (write 222 fifo)
> (read fifo)
111
> (read fifo)
222
> (write 333 fifo)
> (read fifo)
333

And another one is tcp-server ports whose elements are the connections received at the indicated interface and port number:

> (define server (open-tcp-server "localhost:12345"))
> (let loop ()
    (let ((p (read server)))
      (pretty-print p)
      (display "hello\n" p)
      (close-port p)
      (loop)))
#<input-output-port #3 (tcp-client)>  ;; after first “telnet localhost 12345”
#<input-output-port #4 (tcp-client)>  ;; after second “telnet localhost 12345”
#<input-output-port #5 (tcp-client)>  ;; after third “telnet localhost 12345”

Unifying generators through ports has the advantage of a single way to control waiting on the next value (rather than having a different API depending on the nature of the generator).  In Gambit you can call (input-port-timeout-set! port timeout [thunk]) to set an action to perform if a read operation waits for longer than a certain amount of time.  There’s also (output-port-timeout-set! port timeout [thunk]) for situations where writes may have to wait.

Marc