Changeset 40431 in project


Ignore:
Timestamp:
09/07/21 19:43:17 (3 weeks ago)
Author:
Zipheir
Message:

Document text ports.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/srfi-135

    r40427 r40431  
    988988are provided, then only a subtext(ual) of ''textual'' is written.
    989989
     990==== Text ports
     991
     992Text ports are analogous to R7RS string ports.
     993
     994Text ports are currently implemented as wrapped string ports. A
     995direct implementation is a major TODO for this library.
     996
     997The following procedures are extensions to SRFI 135.
     998
     999<procedure>(open-input-textual textual) → input-port</procedure>
     1000
     1001Returns a textual input port which delivers characters from
     1002''textual''.
     1003
     1004Example:
     1005
     1006<enscript highlight="scheme">(let ((p (open-input-textual (text #\a #\b #\c #\newline))))
     1007  (read-line p))
     1008  ⇒ "abc"
     1009</enscript>
     1010
     1011<procedure>(open-output-text) → output-port</procedure>
     1012
     1013Returns a textual output port that accumulates characters for
     1014retrieval by {{get-output-text}}.
     1015
     1016<procedure>(get-output-text port) → text</procedure>
     1017
     1018Returns a text of the characters written to ''port'' so far, in the
     1019order in which they were output. It is an error if ''port'' was not
     1020created by {{open-output-text}}.
     1021
     1022Example:
     1023
     1024<enscript highlight="scheme">(let ((p (open-output-text)))
     1025  (display "hello " p)
     1026  (display "dave" p)
     1027  (write-char #\newline p)
     1028  (get-output-text p))
     1029  ⇒ «hello dave»
     1030</enscript>
     1031
    9901032== About This Egg
    9911033
Note: See TracChangeset for help on using the changeset viewer.