Dirk Herrmann <Herrmann@ida.ing.tu-bs.de> wrote:
+---------------
| Is there an implementation of scheme that supports in addition to file
| and string ports something like function ports? For example:
| (open-input-function
| (lambda ()
| (<some code that returns characters or strings>)))
+---------------
Yes, several implementations -- e.g., MzScheme, SCM, to name just two --
provide "custom" or "soft" ports (their respective names), for which
the basic actions on ports (e.g., read-char, char-ready?, close etc.)
are provided by the user as Scheme procedures when creating the port.
For Mzscheme, the interface is:
(make-input-port getc-proc char-ready?-proc close-proc)
(make-output-port write-string-proc close-proc)
And for SCM:
(make-soft-port a-vector-of-procs IO-modes)
where the elements [not all are needed] of the vector are:
0 procedure accepting one character for output
1 procedure accepting a string for output
2 thunk for flushing output
3 thunk for getting one character
4 thunk for closing port (not by garbage collection)
-Rob
-----
Rob Warnock, 8L-855 rpw3@sgi.com
Applied Networking http://reality.sgi.com/rpw3/
Silicon Graphics, Inc. Phone: 650-933-1673
1600 Amphitheatre Pkwy. FAX: 650-933-0511
Mountain View, CA 94043 PP-ASEL-IA