Input and Output

Gamma: Version 4.0
Prev |  | Next

# Chapter 12. Input and Output

# 12.1. Referencing Files

As in C, there are two ways to reference a file in Gamma, using a descriptor or a pointer.

A file descriptor is an integer that identifies an open file within a process. This is the lowest-level handle available for interacting with the open file. Disk files, pseudo-ttys, IP sockets, UNIX-domain sockets, pipes and other facilities all offer interaction through file descriptors.

A file pointer is an abstraction of the file that adds buffering on input and output. This would be of type FILE* in C. The reason this exists is that it is very inefficient to use a file descriptor, which does not perform any in-process buffering where many reads and writes are being performed. The file pointer stores many write requests until it has enough data to perform a more efficient write to disk, hopefully in multiples of the disk block size.

In Gamma, a file pointer is an opaque structure (the internals are not visible to the programmer) that is effectively a buffered FILE*. (See the note in `open`.) It's abstracted a little further to also include strings as file pointers, when they are opened using `open_string`.

Some Gamma I/O functions work with file descriptors (generally those that start with `fd_`), others work with file pointers, and a few work with both.

Prev | Home | Next
Literal Syntax and Evaluation | Up | Lisp and Gamma I/O mechanisms

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.