close

close — closes an open file.

Syntax

close (file)

		

Arguments

file

A file pointer to a previously opened file. This may be either a file in the file system, or a string opened for read and write.

Returns

t if the file had been open and was closed successfully, else nil.

Description

This function closes a previously opened file. It is not strictly necessary, as the file will be closed when the garbage collector recognizes that there are no references to the file, but it is extremely good policy. This function will close a string opened for reading and writing as well.

Example

Gamma> fp = open("myfile.dat","r");
#<File:"myfile.dat">
Gamma> close(fp);
t
Gamma> fp;
#<Destroyed Instance>
Gamma>  
		

See Also

fd_close, open, open_string