close(@stream_or_alias, @close_options) [ISO]

This built-in predicate closes a sink/source, how the stream is closed is determined by the list of close-options. The stream close option defined in standard prolog is force/1. If the close option 'force(true)' is specified then any resource or system errors are ignored while closing the stream, if 'force(false)' is specified then closing the stream stops on detecting an error, this is the default option.

see also: at_end_of_stream/0 at_end_of_stream/1 close/1 close_user_streams/0 current_input/1 current_output/1 flush_output/0 flush_output/1 open/3 open/4 prolog I/O set_input/1 set_output/1 set_stream_position/2 set_stream_property/2 stream_property/2

Example
close(user_input, [force(true)]). system and resource errors are ignored succeeds if the stream user_input is open and if the stream was successfully closed

 

Exceptions  
list of options is a variable or a list with an element which is a variable an instantiation_error exception is thrown
the list of Options is neither a variable nor a list a type_error(list, Options) exception is thrown, the variable Options is replaced by the incorrect close-options parameter of close/2
an Element of the close options list is neither a variable nor a close option a domain_error(close_option, Element) exception is thrown, variable Element of the exception is assigned the incorrect list element
stream_or_alias is a variable an instantiation_error exception is thrown
stream_or_alias is neither a variable nor a stream term nor an alias a domain_error(stream_or_alias, Stream) exception is thrown, the variable Stream is assigned the incorrect stream_or_alias term
stream_or_alias is not associated with an open stream an existence_error(stream, Stream) exception is thrown

 

 

info@trinc-prolog.com