Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Input and Output   [Contents][Index]


6.14.9 Default Ports for Input, Output and Errors

Scheme Procedure: current-input-port
C Function: scm_current_input_port ()

Return the current input port. This is the default port used by many input procedures.

Initially this is the standard input in Unix and C terminology. When the standard input is a tty the port is unbuffered, otherwise it’s fully buffered.

Unbuffered input is good if an application runs an interactive subprocess, since any type-ahead input won’t go into Guile’s buffer and be unavailable to the subprocess.

Note that Guile buffering is completely separate from the tty “line discipline”. In the usual cooked mode on a tty Guile only sees a line of input once the user presses Return.

Scheme Procedure: current-output-port
C Function: scm_current_output_port ()

Return the current output port. This is the default port used by many output procedures.

Initially this is the standard output in Unix and C terminology. When the standard output is a tty this port is unbuffered, otherwise it’s fully buffered.

Unbuffered output to a tty is good for ensuring progress output or a prompt is seen. But an application which always prints whole lines could change to line buffered, or an application with a lot of output could go fully buffered and perhaps make explicit force-output calls (see Buffering) at selected points.

Scheme Procedure: current-error-port
C Function: scm_current_error_port ()

Return the port to which errors and warnings should be sent.

Initially this is the standard error in Unix and C terminology. When the standard error is a tty this port is unbuffered, otherwise it’s fully buffered.

Scheme Procedure: set-current-input-port port
Scheme Procedure: set-current-output-port port
Scheme Procedure: set-current-error-port port
C Function: scm_set_current_input_port (port)
C Function: scm_set_current_output_port (port)
C Function: scm_set_current_error_port (port)

Change the ports returned by current-input-port, current-output-port and current-error-port, respectively, so that they use the supplied port for input or output.

Scheme Procedure: with-input-from-port port thunk
Scheme Procedure: with-output-to-port port thunk
Scheme Procedure: with-error-to-port port thunk

Call thunk in a dynamic environment in which current-input-port, current-output-port or current-error-port is rebound to the given port.

C Function: void scm_dynwind_current_input_port (SCM port)
C Function: void scm_dynwind_current_output_port (SCM port)
C Function: void scm_dynwind_current_error_port (SCM port)

These functions must be used inside a pair of calls to scm_dynwind_begin and scm_dynwind_end (see Dynamic Wind). During the dynwind context, the indicated port is set to port.

More precisely, the current port is swapped with a ‘backup’ value whenever the dynwind context is entered or left. The backup value is initialized with the port argument.


Next: , Previous: , Up: Input and Output   [Contents][Index]