close/1

Synopsis

close(+Stream)

closes the stream corresponding to Stream.

Arguments


Stream stream_object
stream or file specification

Description

If Stream is a stream object, then if the corresponding stream is open, it will be closed; otherwise, close/1 succeeds immediately, taking no action.

If Stream is a file specification, the corresponding stream will be closed, provided that the file was opened by see/1 or tell/1.

Exceptions

Stream errors (see ref-iou-sfh-est), plus:


permission_error
File not opened by see/1 or tell/1.
domain_error
Stream is neither a filename nor a stream.

Examples

In this example, foo will be closed:

     see(foo),
     ...
     close(foo)
     

However, in this example, a permission error will be raised and foo will not be closed:

     open(foo, read, S),
     ...
     close(foo)
     

Here, close(S) should have been used.

See Also

see/1, tell/1, open/[3,4], write_canonical/[1,2]