12.4. Reading

12.4.1. Reading Gamma Expressions

Any valid Gamma expression can be read by the Gamma reader using the function read. The read function will read from the current location in a file, skipping over comments, until it encounters a character which could be the beginning of a Gamma expression. The reader then constructs the shortest possible complete expression from the input and returns that. A complete Gamma expression may be as simple as a number, or as complex as a complete function definition or complex data object. The reader ignores white space, except as a token separator. It may be interesting to note that the entire Gamma mainline is essentially just a simple loop:

while ((exp = read (input_file)) != _eof_) eval (exp);
	  

12.4.2. Reading Arbitrary ASCII Data

Gamma allows the programmer to read arbitrary ASCII data using the function read_line, which will read from the current file position to the first carriage return, regardless of the syntactic validity of the data on the line. If data fields are known to be separated by white space, then the read function using Lisp syntax may also be used to read a single field. Notice that the read function will treat an unquoted string of ASCII characters as a symbol, not as a string. It is more common when dealing with line-formatted data to use read_line followed by string_split.

12.4.3. Reading Binary Data

Gamma provides a number of functions for reading binary data. These functions all begin with the prefix read_, and they read according to the rules for C data types for the particular platform. For example, read_char will read a decimal representation of a string of length 1 containing a single character.