Changes between Version 2 and Version 3 of BinaryPortsCowan


Ignore:
Timestamp:
06/29/11 01:15:41 (6 years ago)
Author:
cowan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BinaryPortsCowan

    v2 v3  
    1 == Introduction == 
     1= I no longer support this proposal = 
    22 
    3 This is my proposal for binary ports in small R7RS.  It assumes, but partly overrides, PortsCowan.  In particular, the version of the `buffering` key described there is replaced by the `buffer` key here. 
    4  
    5 Under this proposal, it is no longer true that all binary ports are also character ports.  The user may create a file port that is either a character port, a binary port, or both.  String ports are character ports; blob ports are binary ports. 
    6  
    7 == Opening file ports == 
    8  
    9 To open a binary file port, use any of the file-opening operations, passing the `binary` key with a true value.  To open a character file port, use any of the 
    10 file-opening operations, passing the `character` key with a true value.  If either the `character` key or the `binary` key is not present, it is assumed to be false.  However, if the whole file spec takes the form of a string rather than a list, the `character` key is assumed to be true. 
    11  
    12 If the `buffer` key is false, the port must not be buffered by the implementation.  If the key is true or is not present, the port may be buffered.  Buffered character ports that are ''not'' binary ports may have both a character buffer and a binary buffer, but buffered character ports that ''are'' binary ports must not have a character buffer.  This permits safe interleaving of character and binary operations. 
    13  
    14 Here are the above rules in tabular form: 
    15  
    16 ||`character`||`binary`||`buffer`||returns:|| 
    17 ||false||false||false||undefined, no buffering|| 
    18 ||false||false||true||undefined|| 
    19 ||false||true||false||binary port, no buffering|| 
    20 ||false||true||true||binary port, may have buffer|| 
    21 ||true||false||false||character port, no buffering|| 
    22 ||true||false||true||character port, may have binary buffer and/or character buffer|| 
    23 ||true||true||false||character and binary port, no buffering|| 
    24 ||true||true||true||character and binary port, may have binary buffer, must not have character buffer|| 
    25  
    26 == Operations on character and binary ports == 
    27  
    28  * Character ports allow the `read-char`, `peek-char`, `char-ready`, and the layered `read`, `write`, and `display` operations; they answer `#t` to `character-port?`. 
    29  
    30  * Binary ports allow the `read-u8`, `peek-u8`, and `u8-ready` operations; they answer `#t` to `binary-port?`. 
    31  
    32  * Both kinds of ports can be handed to `port?`, `input-port?`, `output-port?`, `character-port`, `binary-port`, `port-open?`, `close-input-port`, and `close-output-port`. 
     3Please see PortsShinn, which is a compromise between Alex and me.