Skip to content

Latest commit

 

History

History
1071 lines (610 loc) · 37.3 KB

scml_base_io.md

File metadata and controls

1071 lines (610 loc) · 37.3 KB

Module scml_base_io

Scheme base library for input and output

. __Authors:__ Joseph Wayne Norton ([`[email protected]`](mailto:[email protected])).

Function Index

'$scml_exports'/0
'binary-port?'/1

Returns #t if obj is a binary port, otherwise returns #f.

.
'call-with-port'/5

Calls proc with port as an argument. If proc returns, then the port is closed and the values yielded by the proc are returned. Otherwise, the port is automatically closed when there are no longer any references to the port.

.
'char-ready?'/0Equivalent to 'char-ready?'('current-input-port'()).
'char-ready?'/1

Returns #t if a character is ready on the textual input port or if port is at the end of the file, otherwise returns #f.

.
'close-input-port'/1

Close the resource associated with port, rendering the input port incapable of delivering data. This procedure has no effect if the input port has already been closed. It is an error to apply this procedure to a port which is not an input port.

.
'close-output-port'/1

Close the resource associated with port, rendering the input port incapable of delivering data. This procedure has no effect if the input port has already been closed. It is an error to apply this procedure to a port which is not an input port.

.
'close-port'/1

Close the resource associated with port, rendering the port incapable of delivering or accepting data. This procedure has no effect if the port has already been closed.

.
'current-error-port'/0

Returns the current error port. The initial value is the default error port. The default error port is a textual port. The current-error-port procedures behave like a parameter object, which can be overridden with parameterize.

.
'current-error-port'/1

Returns the converter procedure for the current error port.

.
'current-error-port'/2

Saves the given port as the current error port. Returns #f.

.
'current-input-port'/0

Returns the current input port. The initial value is the default input port. The default input port is a textual port. The current-input-port procedures behave like a parameter object, which can be overridden with parameterize.

.
'current-input-port'/1

Returns the converter procedure for the current input port.

.
'current-input-port'/2

Saves the given port as the current input port. Returns #f.

.
'current-output-port'/0

Returns the current output port. The initial value is the default output port. The default output port is a textual port. The current-output-port procedures behave like a parameter object, which can be overridden with parameterize.

.
'current-output-port'/1

Returns the converter procedure for the current output port.

.
'current-output-port'/2

Saves the given port as the current output port. Returns #f.

.
'eof-object'/0

Returns an end-of-file object.

.
'eof-object?'/1

Returns #t if obj is an end-of-file object, otherwise returns #f.

.
'flush-output-port'/0Equivalent to 'flush-output-port'('current-output-port'()).
'flush-output-port'/1

Flushes any buffered output from the buffer of output port to the underlying file or device.

.
'get-output-bytevector'/1

Returns a bytevector consisting of the bytes that have been output to the port so far in the order they were output. It is an error if port is not a binary output port.

.
'get-output-string'/1

Returns a string consisting of the characters that have been output to the port so far in the order they were output. It is an error if port is not a textual output port.

.
'input-port-open?'/1

Returns #t if port is still open and capable of performing input, otherwise returns #t.

.
'input-port?'/1

Returns #t if obj is an input port, otherwise returns #f.

.
'open-input-bytevector'/1

Returns a binary input port that delivers bytes from the given bytevector.

.
'open-input-string'/1

Returns a textual input port that delivers characters from the given string.

.
'open-output-bytevector'/0

Returns a binary output port that will accumulate bytes for retrieval by get-output-bytevector.

.
'open-output-string'/0

Returns a textual output port that will accumulate characters for retrieval by get-output-string.

.
'output-port-open?'/1

Returns #t if port is still open and capable of performing output, otherwise returns #t.

.
'output-port?'/1

Returns #t if obj is an output port, otherwise returns #f.

.
'peek-char'/0Equivalent to 'peek-char'('current-input-port'()).
'peek-char'/1

Returns the next character available from the textual input port, but without updating the port to point to the following character. If no more characters are available, an end-of-file object is returned.

.
'peek-u8'/0Equivalent to 'peek-u8'('current-input-port'()).
'peek-u8'/1

Returns the next byte available from the binary input port, but without updating the port to point to the following byte. If not more bytes are available, an end-of-file object is returned.

.
'port?'/1

Returns #t if obj is a port, otherwise returns #f.

.
'read-bytevector!'/1

unsupported

.
'read-bytevector!'/2

unsupported

.
'read-bytevector!'/3

unsupported

.
'read-bytevector!'/4

unsupported

.
'read-bytevector'/1Equivalent to 'read-bytevector'(K, 'current-input-port'()).
'read-bytevector'/2

Reads the next k bytes, or as many as are available before the end of file, from the binary input port into a bytevector in left-to-right order and returns the bytevector. If no bytes are available before the end of file, an end-of-file object is returned.

.
'read-char'/0Equivalent to 'read-char'('current-input-port'()).
'read-char'/1

Returns the next character available from the textual input port, updating the port to point to the following character. If no more characters are available, an end-of-file object is returned.

.
'read-line'/0Equivalent to 'read-line'('current-input-port'()).
'read-line'/1

Returns the next line of text available from the textual input port, updating the port to point to the following character. If an end of line is read, a string containing all of the text up to (but not including) the end of file is returned, and the port is updated to point just past the end of line. If an end of file is encountered before any end of line is read, but some characters have been read, a string containing those characters is returned. If an end of file is encountered before any characters are read, an end-of-file object is returned. For the purpose of this procedure, an end of line consists of either a linefeed character, a carriage return character, or a sequence of a carriage return character followed by a linefeed character.

.
'read-string'/1Equivalent to 'read-string'(K, 'current-input-port'()).
'read-string'/2

Reads the next k characters, or as many as are available before the end of file, from the textual input port into a string in left-to-right order and returns the string. If no characters are available before the end of file, an end-of-file object is returned.

.
'read-u8'/0Equivalent to 'read-u8'('current-input-port'()).
'read-u8'/1

Returns the next byte available from the binary input port, updating the port to point to the following byte. If no more bytes are available, an end-of-file object is returned.

.
'textual-port?'/1

Returns #t if obj is a textual port, otherwise returns #f.

.
'u8-ready?'/0Equivalent to 'u8-ready?'('current-input-port'()).
'u8-ready?'/1

Returns #t if a byte is ready on the binary input port or if port is at the end of the file, otherwise returns #f.

.
'write-bytevector'/1Equivalent to 'write-bytevector'(V, 'current-output-port'()).
'write-bytevector'/2Equivalent to 'write-bytevector'(V, 'current-output-port'(), 0, 'bytevector-length'(V)).
'write-bytevector'/3Equivalent to 'write-bytevector'(V, 'current-output-port'(), Start, 'bytevector-length'(V)).
'write-bytevector'/4

Writes the bytes of bytevector from start to end in left-to-right order to the binary output port.

.
'write-char'/1Equivalent to 'write-char'(C, 'current-output-port'()).
'write-char'/2

Writes the character char to the given textual output port.

.
'write-string'/1Equivalent to 'write-string'(S, 'current-output-port'()).
'write-string'/2Equivalent to 'write-string'(S, 'current-output-port'(), 0).
'write-string'/3Equivalent to 'write-string'(S, 'current-output-port'(), Start, 'string-length'(S)).
'write-string'/4

Writes the characters of string from start to end in left-right order to the textual output port.

.
'write-u8'/1Equivalent to 'write-u8'(B, 'current-output-port'()).
'write-u8'/2

Writes the byte to the given binary output port.

.
newline/0Equivalent to newline('current-output-port'()).
newline/1

Writes an end of line to the textual output port.

.

Function Details

'$scml_exports'/0


'$scml_exports'() -> [{scm_symbol(), scmi_nip()}]



'binary-port?'/1


'binary-port?'(Obj::scm_obj()) -> scm_boolean()



Returns #t if obj is a binary port, otherwise returns #f.

'call-with-port'/5


'call-with-port'(Port::scm_port(), Proc::scm_proc(), Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_obj()



Calls proc with port as an argument. If proc returns, then the port is closed and the values yielded by the proc are returned. Otherwise, the port is automatically closed when there are no longer any references to the port.

'char-ready?'/0


'char-ready?'() -> scm_boolean()



Equivalent to 'char-ready?'('current-input-port'()).

'char-ready?'/1


'char-ready?'(Port::scm_port()) -> scm_boolean()



Returns #t if a character is ready on the textual input port or if port is at the end of the file, otherwise returns #f.

'close-input-port'/1


'close-input-port'(Port::scm_port()) -> scm_false()



Close the resource associated with port, rendering the input port incapable of delivering data. This procedure has no effect if the input port has already been closed. It is an error to apply this procedure to a port which is not an input port.

'close-output-port'/1


'close-output-port'(Port::scm_port()) -> scm_false()



Close the resource associated with port, rendering the input port incapable of delivering data. This procedure has no effect if the input port has already been closed. It is an error to apply this procedure to a port which is not an input port.

'close-port'/1


'close-port'(Port::scm_port()) -> scm_false()



Close the resource associated with port, rendering the port incapable of delivering or accepting data. This procedure has no effect if the port has already been closed.

'current-error-port'/0


'current-error-port'() -> scm_port()



Returns the current error port. The initial value is the default error port. The default error port is a textual port. The current-error-port procedures behave like a parameter object, which can be overridden with parameterize.

'current-error-port'/1


'current-error-port'(X1::'?SCMIPARAMCVT') -> scm_proc()



Returns the converter procedure for the current error port.

'current-error-port'/2


'current-error-port'(X1::'?SCMIPARAMSET', Port::scm_port()) -> scm_false()



Saves the given port as the current error port. Returns #f.

'current-input-port'/0


'current-input-port'() -> scm_port()



Returns the current input port. The initial value is the default input port. The default input port is a textual port. The current-input-port procedures behave like a parameter object, which can be overridden with parameterize.

'current-input-port'/1


'current-input-port'(X1::'?SCMIPARAMCVT') -> scm_proc()



Returns the converter procedure for the current input port.

'current-input-port'/2


'current-input-port'(X1::'?SCMIPARAMSET', Port::scm_port()) -> scm_false()



Saves the given port as the current input port. Returns #f.

'current-output-port'/0


'current-output-port'() -> scm_port()



Returns the current output port. The initial value is the default output port. The default output port is a textual port. The current-output-port procedures behave like a parameter object, which can be overridden with parameterize.

'current-output-port'/1


'current-output-port'(X1::'?SCMIPARAMCVT') -> scm_proc()



Returns the converter procedure for the current output port.

'current-output-port'/2


'current-output-port'(X1::'?SCMIPARAMSET', Port::scm_port()) -> scm_false()



Saves the given port as the current output port. Returns #f.

'eof-object'/0


'eof-object'() -> scm_eof()



Returns an end-of-file object.

'eof-object?'/1


'eof-object?'(Obj::scm_obj()) -> scm_boolean()



Returns #t if obj is an end-of-file object, otherwise returns #f.

'flush-output-port'/0


'flush-output-port'() -> scm_false()



Equivalent to 'flush-output-port'('current-output-port'()).

'flush-output-port'/1


'flush-output-port'(Port::scm_port()) -> scm_false()



Flushes any buffered output from the buffer of output port to the underlying file or device.

'get-output-bytevector'/1


'get-output-bytevector'(Port::scm_port()) -> scm_bytevector()



Returns a bytevector consisting of the bytes that have been output to the port so far in the order they were output. It is an error if port is not a binary output port.

'get-output-string'/1


'get-output-string'(Port::scm_port()) -> scm_string()



Returns a string consisting of the characters that have been output to the port so far in the order they were output. It is an error if port is not a textual output port.

'input-port-open?'/1


'input-port-open?'(Port::scm_port()) -> scm_boolean()



Returns #t if port is still open and capable of performing input, otherwise returns #t.

'input-port?'/1


'input-port?'(Obj::scm_obj()) -> scm_boolean()



Returns #t if obj is an input port, otherwise returns #f.

'open-input-bytevector'/1


'open-input-bytevector'(Bytevector::scm_bytevector()) -> scm_port()



Returns a binary input port that delivers bytes from the given bytevector.

'open-input-string'/1


'open-input-string'(String::scm_string()) -> scm_port()



Returns a textual input port that delivers characters from the given string.

'open-output-bytevector'/0


'open-output-bytevector'() -> scm_port()



Returns a binary output port that will accumulate bytes for retrieval by get-output-bytevector.

'open-output-string'/0


'open-output-string'() -> scm_port()



Returns a textual output port that will accumulate characters for retrieval by get-output-string.

'output-port-open?'/1


'output-port-open?'(Port::scm_port()) -> scm_boolean()



Returns #t if port is still open and capable of performing output, otherwise returns #t.

'output-port?'/1


'output-port?'(Obj::scm_obj()) -> scm_boolean()



Returns #t if obj is an output port, otherwise returns #f.

'peek-char'/0


'peek-char'() -> scm_char() | scm_eof()



Equivalent to 'peek-char'('current-input-port'()).

'peek-char'/1


'peek-char'(Port::scm_port()) -> scm_char() | scm_eof()



Returns the next character available from the textual input port, but without updating the port to point to the following character. If no more characters are available, an end-of-file object is returned.

'peek-u8'/0


'peek-u8'() -> scm_byte() | scm_eof()



Equivalent to 'peek-u8'('current-input-port'()).

'peek-u8'/1


'peek-u8'(Port::scm_port()) -> scm_byte() | scm_eof()



Returns the next byte available from the binary input port, but without updating the port to point to the following byte. If not more bytes are available, an end-of-file object is returned.

'port?'/1


'port?'(Obj::scm_obj()) -> scm_boolean()



Returns #t if obj is a port, otherwise returns #f.

'read-bytevector!'/1


'read-bytevector!'(V::scm_bytevector()) -> scm_k() | scm_eof()



unsupported

'read-bytevector!'/2


'read-bytevector!'(V::scm_bytevector(), Port::scm_port()) -> scm_k() | scm_eof()



unsupported

'read-bytevector!'/3


'read-bytevector!'(V::scm_bytevector(), Port::scm_port(), Start::scm_start()) -> scm_k() | scm_eof()



unsupported

'read-bytevector!'/4


'read-bytevector!'(V::scm_bytevector(), Port::scm_port(), Start::scm_start(), End::scm_end()) -> scm_k() | scm_eof()



unsupported

'read-bytevector'/1


'read-bytevector'(K::scm_k()) -> scm_bytevector() | scm_eof()



Equivalent to 'read-bytevector'(K, 'current-input-port'()).

'read-bytevector'/2


'read-bytevector'(K::scm_k(), Port::scm_port()) -> scm_bytevector() | scm_eof()



Reads the next k bytes, or as many as are available before the end of file, from the binary input port into a bytevector in left-to-right order and returns the bytevector. If no bytes are available before the end of file, an end-of-file object is returned.

'read-char'/0


'read-char'() -> scm_char() | scm_eof()



Equivalent to 'read-char'('current-input-port'()).

'read-char'/1


'read-char'(Port::scm_port()) -> scm_char() | scm_eof()



Returns the next character available from the textual input port, updating the port to point to the following character. If no more characters are available, an end-of-file object is returned.

'read-line'/0


'read-line'() -> scm_string() | scm_eof()



Equivalent to 'read-line'('current-input-port'()).

'read-line'/1


'read-line'(Port::scm_port()) -> scm_string() | scm_eof()



Returns the next line of text available from the textual input port, updating the port to point to the following character. If an end of line is read, a string containing all of the text up to (but not including) the end of file is returned, and the port is updated to point just past the end of line. If an end of file is encountered before any end of line is read, but some characters have been read, a string containing those characters is returned. If an end of file is encountered before any characters are read, an end-of-file object is returned. For the purpose of this procedure, an end of line consists of either a linefeed character, a carriage return character, or a sequence of a carriage return character followed by a linefeed character.

'read-string'/1


'read-string'(K::scm_k()) -> scm_string() | scm_eof()



Equivalent to 'read-string'(K, 'current-input-port'()).

'read-string'/2


'read-string'(K::scm_k(), Port::scm_port()) -> scm_string() | scm_eof()



Reads the next k characters, or as many as are available before the end of file, from the textual input port into a string in left-to-right order and returns the string. If no characters are available before the end of file, an end-of-file object is returned.

'read-u8'/0


'read-u8'() -> scm_byte() | scm_eof()



Equivalent to 'read-u8'('current-input-port'()).

'read-u8'/1


'read-u8'(Port::scm_port()) -> scm_byte() | scm_eof()



Returns the next byte available from the binary input port, updating the port to point to the following byte. If no more bytes are available, an end-of-file object is returned.

'textual-port?'/1


'textual-port?'(Obj::scm_obj()) -> scm_boolean()



Returns #t if obj is a textual port, otherwise returns #f.

'u8-ready?'/0


'u8-ready?'() -> scm_boolean()



Equivalent to 'u8-ready?'('current-input-port'()).

'u8-ready?'/1


'u8-ready?'(Port::scm_port()) -> scm_boolean()



Returns #t if a byte is ready on the binary input port or if port is at the end of the file, otherwise returns #f.

'write-bytevector'/1


'write-bytevector'(V::scm_bytevector()) -> scm_false()



Equivalent to 'write-bytevector'(V, 'current-output-port'()).

'write-bytevector'/2


'write-bytevector'(Bytevector::scm_bytevector(), Port::scm_port()) -> scm_false()



Equivalent to 'write-bytevector'(V, 'current-output-port'(), 0,'bytevector-length'(V)).

'write-bytevector'/3


'write-bytevector'(Bytevector::scm_bytevector(), Port::scm_port(), Start::scm_start()) -> scm_false()



Equivalent to 'write-bytevector'(V, 'current-output-port'(), Start,'bytevector-length'(V)).

'write-bytevector'/4


'write-bytevector'(Bytevector::scm_bytevector(), Port::scm_port(), Start::scm_start(), End::scm_end()) -> scm_false()



Writes the bytes of bytevector from start to end in left-to-right order to the binary output port.

'write-char'/1


'write-char'(C::scm_char()) -> scm_false()



Equivalent to 'write-char'(C, 'current-output-port'()).

'write-char'/2


'write-char'(Character::scm_char(), Port::scm_port()) -> scm_false()



Writes the character char to the given textual output port.

'write-string'/1


'write-string'(S::scm_string()) -> scm_false()



Equivalent to 'write-string'(S, 'current-output-port'()).

'write-string'/2


'write-string'(String::scm_string(), Port::scm_port()) -> scm_false()



Equivalent to 'write-string'(S, 'current-output-port'(), 0).

'write-string'/3


'write-string'(String::scm_string(), Port::scm_port(), Start::scm_start()) -> scm_false()



Equivalent to 'write-string'(S, 'current-output-port'(), Start,'string-length'(S)).

'write-string'/4


'write-string'(S::scm_string(), Port::scm_port(), Start::scm_start(), End::scm_end()) -> scm_false()



Writes the characters of string from start to end in left-right order to the textual output port.

'write-u8'/1


'write-u8'(B::scm_byte()) -> scm_false()



Equivalent to 'write-u8'(B, 'current-output-port'()).

'write-u8'/2


'write-u8'(B::scm_byte(), Port::scm_port()) -> scm_false()



Writes the byte to the given binary output port.

newline/0


newline() -> scm_false()



Equivalent to newline('current-output-port'()).

newline/1


newline(Port::scm_port()) -> scm_false()



Writes an end of line to the textual output port.