User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:close [2019/11/11 05:00]
cl:functions:close [2019/12/08 22:00] (current)
Line 1: Line 1:
 +====== Function CLOSE ======
 +
 +====Syntax====
 +  * **close** //stream// ''&​key''​ //abort// → //result//
 +
 +====Arguments and Values====
 +  * //stream// - a //​[[CL:​Glossary:​stream]]//​ (either //​[[CL:​Glossary:​open]]//​ or //​[[CL:​Glossary:​closed]]//​).
 +  * //abort// - a //​[[CL:​Glossary:​generalized boolean]]//​. The default is //​[[CL:​Glossary:​false]]//​.
 +  * //result// - **[[CL:​Constant Variables:​t]]** if the //stream// was //​[[CL:​Glossary:​open]]//​ at the time it was received as an //​[[CL:​Glossary:​argument]]//,​ or //​[[CL:​Glossary:​implementation-dependent]]//​ otherwise.
 +
 +====Description====
 +**close** closes //stream//. Closing a //​[[CL:​Glossary:​stream]]//​ means that it may no longer be used in input or output operations. The act of //​[[CL:​Glossary:​close|closing]]//​ a //​[[CL:​Glossary:​file stream]]// ends the association between the //​[[CL:​Glossary:​stream]]//​ and its associated //​[[CL:​Glossary:​file]]//;​ the transaction with the //​[[CL:​Glossary:​file system]]// is terminated, and input/​output may no longer be performed on the //​[[CL:​Glossary:​stream]]//​.
 +
 +If //abort// is //​[[CL:​Glossary:​true]]//,​ an attempt is made to clean up any side effects of having created //stream//. If //stream// performs output to a file that was created when the //​[[CL:​Glossary:​stream]]//​ was created, the file is deleted and any previously existing file is not superseded.
 +
 +It is permissible to close an already closed //​[[CL:​Glossary:​stream]]//,​ but in that case the //result// is //​[[CL:​Glossary:​implementation-dependent]]//​.
 +
 +After //stream// is closed, it is still possible to perform the following query operations upon it:
 +  * **[[CL:​Functions:​streamp]]**
 +  * **[[CL:​Functions:​pathname]]**
 +  * **[[CL:​Functions:​truename]]**
 +  * **[[CL:​Functions:​merge-pathnames]]**
 +  * **[[CL:​Functions:​pathname-host]]**
 +  * **[[CL:​Functions:​pathname-device]]**
 +  * **[[CL:​Functions:​pathname-directory]]**
 +  * **[[CL:​Functions:​pathname-name]]**
 +  * **[[CL:​Functions:​pathname-type]]**
 +  * **[[CL:​Functions:​pathname-version]]**
 +  * **[[CL:​Functions:​namestring]]**
 +  * **[[CL:​Functions:​file-namestring]]**
 +  * **[[CL:​Functions:​directory-namestring]]**
 +  * **[[CL:​Functions:​host-namestring]]**
 +  * **[[CL:​Functions:​enough-namestring]]**
 +  * **[[CL:​Functions:​open]]**
 +  * **[[CL:​Functions:​probe-file]]**
 +  * **[[CL:​Functions:​directory]]**
 +
 +The effect of **close** on a //​[[CL:​Glossary:​constructed stream]]// is to close the argument //stream// only. There is no effect on the //​[[CL:​Glossary:​constituents]]//​ of //​[[CL:​Glossary:​composite streams]]//​.
 +
 +For a //​[[CL:​Glossary:​stream]]//​ created with **[[CL:​Functions:​make-string-output-stream]]**,​ the result of **[[CL:​Functions:​get-output-stream-string]]** is unspecified after **close**.
 +
 +====Examples====
 +<​blockquote> ​
 +([[CL:​Macros:​defparameter]] *S* ([[CL:​Functions:​make-broadcast-stream]])) <​r>​*S*</​r>​
 +*s* <​r>#<​BROADCAST-STREAM>​ </r>
 +(close *S*) <​r>​[[CL:​Constant Variables:​T]] </r>
 +([[CL:​Functions:​output-stream-p]] *s*) <​r>//​[[CL:​Glossary:​true]]//​ </r>
 +</​blockquote>​
 +
 +====Side Effects====
 +The //stream// is //​[[CL:​Glossary:​closed]]//​ (if necessary). If //abort// is //​[[CL:​Glossary:​true]]//​ and the //stream// is an //​[[CL:​Glossary:​output]]//​ //​[[CL:​Glossary:​file stream]]//, its associated //​[[CL:​Glossary:​file]]//​ might be deleted.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See Also====
 +  * **[[CL:​Functions:​open|Function OPEN]]**
 +
 +====Notes====
 +None.
 +
 +\issue{RETURN-VALUES-UNSPECIFIED:​SPECIFY} \issue{CLOSED-STREAM-FUNCTIONS:​ALLOW-INQUIRY} \issue{CLOSED-STREAM-FUNCTIONS:​ALLOW-INQUIRY} \issue{CLOSE-CONSTRUCTED-STREAM:​ARGUMENT-STREAM-ONLY}