Changes between Version 3 and Version 4 of PortsCowan


Ignore:
Timestamp:
09/02/10 10:12:13 (7 years ago)
Author:
cowan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PortsCowan

    v3 v4  
    22 
    33Here's my proposal for Thing One ports and I/O facilities.  It's fully upward compatible with R5RS, but takes ideas from R6RS, SRFI-91 and SRFI-6.  Many of the concepts are present in R6RS under other names. 
     4 
     5The new features beyond R5RS are: 
     6 
     7 * partial control of buffering, character encoding, newline translation, and Scheme case sensitivity 
     8 * string ports (SRFI 6 compatible) 
     9 * binary ports and blob ports (the binary version of string ports) 
     10 * `current-error-port`, `flush-output-port`, `read-line`, `delete-file`, and `file-exists?` from R6RS 
    411 
    512== Port model == 
     
    1118== Filename model == 
    1219 
    13 In this proposal, a filename may be specified either as a string or as a ''settings list'', which is a (disembodied) property list where every key is a symbol ending in a colon.  For convenience, these symbols are also defined as identifiers.  Implementations MUST support the following keys: 
     20In this proposal, a filename may be specified either as a string or as a ''settings list'', which is a list of alternating ''keys'' and ''values'' where every key is a symbol ending in a colon.  For convenience, these symbols are also defined as identifiers.  Implementations MUST support the following keys: 
    1421 
    15 `path:` 
     22 `path:`:: 
    1623 
    17 Specifies the filename.  The interpretation of filenames is implementation-dependent.  There is no default value, but implementations MAY accept other keys in lieu of this one for opening non-file ports. 
     24 Specifies the filename.  The interpretation of filenames is implementation-dependent.  There is no default value, but implementations MAY accept other keys in lieu of this one for opening non-file ports. 
    1825 
    19 `buffering:` 
     26 `buffering:`:: 
    2027 
    21 Specifies what kind of buffering is present.  The value `#f` means there is no buffering; `binary` means that there is a binary buffer but no character buffer; `#t` means there are both character and binary buffering.  Other values MAY be specified by an implementation.  Buffer sizes are implementation-dependent.  The default value is implementation-dependent. 
     28 Specifies what kind of buffering is present.  The value `#f` means no buffering is employed; `binary` means that there is a binary buffer but no character buffer; `#t` means there are both character and binary buffering.  Other values MAY be specified by an implementation.  Buffer sizes are implementation-dependent.  The default value is implementation-dependent. 
    2229 
    23 `encoding:` 
     30 `encoding:`:: 
    2431 
    25 Specifies what character encoding to use on a binary port.  The value `US-ASCII` MUST be supported.  The values `ISO-8859-1` and `UTF-8` SHOULD be supported if the implementation contains the appropriate repertoire of characters.  Other values MAY be supported.  The default value is implementation-dependent. 
     32 Specifies what character encoding to use on a binary port.  The value `US-ASCII` MUST be supported.  The values `ISO-8859-1` and `UTF-8` SHOULD be supported if the implementation contains the appropriate repertoire of characters.  Other values MAY be supported, which SHOULD appear in the [http://www.iana.org/assignments/character-sets IANA list of encodings].  The default value is implementation-dependent. 
    2633 
    27 If a BOM (Byte Order Mark, U+FEFF) is present at the beginning of input on a port encoded as UTF-8, it is skipped.  A BOM is not automatically written on output.  Implementations MAY provide a way around this. 
     34 If a BOM (Byte Order Mark, U+FEFF) is present at the beginning of input on a port encoded as UTF-8, it is skipped.  A BOM is not automatically written on output.  Implementations MAY provide a way around this. 
    2835 
    29 `newline:` 
     36 `newline:`:: 
    3037 
    31 Specifies how to translate newlines.  The value `#f` means that there is no translation.  Any other value causes all of CR, LF, CR+LF, NEL, CR+NEL, and U+2028 to be translated to `#\newline` on input.  On output, the values `cr`, `lf`, and `crlf` mean that `#\newline` is translated to CR, LF, or CR+LF respectively.  Other values MAY be specified by an implementation.  The default value is implementation-dependent. 
     38 Specifies how to translate newlines.  The value `#f` means that no translation is performed.  Any other value causes all of CR, LF, CR+LF, NEL (U+0085), CR+NEL, and LS (U+2028) to be translated to `#\newline` on input.  On output, the translation is implementation-dependent.  Other values MAY be specified by an implementation.  The default value is implementation-dependent. 
    3239 
    33 `case-sensitive:` 
     40 `case-sensitive:`:: 
    3441 
    35 Specifies if Scheme symbols are read from the port case-sensitively or not.  The value `#f` means that upper-case letters in symbols are translated to lower case unless escaped; `#t` means that no translation is done.  The default value is implementation-dependent. 
     42 Specifies if Scheme symbols are read from the port case-sensitively or not.  The value `#f` means that upper-case letters in symbols are translated to lower case unless escaped; `#t` means that no translation is done.  The default value is implementation-dependent. 
    3643 
    3744Implementations MAY support other keys. 
     
    4451=== Port objects === 
    4552 
    46 `(input-port? `''port''`)` 
     53`(input-port? `''obj''`)` 
    4754 
    48 `(output-port? `''port''`)` 
     55`(output-port? `''obj''`)` 
    4956 
    5057Same as R5RS, but also return true on input/output ports. 
     
    8491=== Character I/O === 
    8592 
    86 `(character-port? `''port''`)` 
     93`(character-port? `''obj''`)` 
    8794 
    88 Returns `#t` if ''port'' is a character port.  SRFI 91 calls this `char-port`.  Implementations may define other kinds of character ports. 
     95Returns `#t` if ''obj'' is a character port.  SRFI 91 calls this `char-port`.  Implementations may define other kinds of character ports. 
    8996 
    9097`(read-char `[ ''character-input-port'' ]`)` 
     
    116123Note that string ports are character ports, but not binary ports, so these procedures do not apply to them.  Implementations MAY support other kinds of binary ports such as process ports or stream socket ports. 
    117124 
    118 `(binary-port? `''port''`)` 
     125`(binary-port? `''obj''`)` 
    119126 
    120 Returns `#t` if ''port'' is a binary port.  SRFI 91 calls this `byte-port?`. 
     127Returns `#t` if ''obj'' is a binary port.  SRFI 91 calls this `byte-port?`. 
    121128 
    122129`(read-u8 `[ ''binary-input-port'' ]`)`