read

read — reads a Lisp expression from a file.

Syntax

read (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

The next Lisp expression in the file, or _eof_.

Description

This function reads one Lisp expression from the given file. The file must have been opened before this call with the open or open_string functions. White space and newline characters are ignored during a read. If the end of file is reached during the read call, the message "Unexpected end of file" is returned. read does not evaluate the expressions it reads.

Example

The file "myreadfile.dat" contains the following:

 (a b (c d e))
"A message"  (+ 2 3)

Successive calls to read will produce:

Gamma> fp = open ("myreadfile.dat", "r");
#<File:"myreadfile.dat">
Gamma> read (fp);
(a b (c d e))
Gamma> read (fp);
"A message"
Gamma> read (fp);
(+ 2 3)
Gamma> read (fp);
"Unexpected end of file"
Gamma>  
		

See Also

read_char, read_double, read_float, read_line, read_long, read_short, read_until