File contents and caching: System memory is limited, and filesystem access is slow. Thus we necessarily want to encourage user programs to keep as little data in memory as possible, but not too little. Ideally, an arbitrary large file should be freely editable on a system with only 192 KB of memory. YANIX addresses system memory limitations by heavily discouraging programs from working with the entirety of a file's contents at once. Programs should not be constructed to depend on keeping the entirety of a file's contents in memory--YANIX will automatically cache as much of a file as it can. Programs should instead work with files one chunk at a time, whether that be chunks of a certain size or something higher-level like individual lines. To this end, the `contents' field of a file handle allows several different modes by which the file may be either iterated over (with contents.iterate(), described below) or indexed directly: delimit - split file contents by a given delimiter chunk - chunks of an arbitrary size, as little as 1 byte block - blocks of the native filesystem size This is the behavior of contents.iterate(): iterate(mode[, option][, start][, finish]) -> iterator Returns an iterator over the file using the given format. Optional `start' and `finish' indices indicate bounds of the iteration, with the same semantics as a `for i=start, finish` loop. These will be sufficient for a significant portion of how files are accessed. It will not be sufficient for all uses. For those cases, `contents' implements a few of the `string' API functions, and some extensions to address the Lua API's lack of in-place string modifications. An example of the utility of this API is elimination of the need for text editors to manage an internal buffer of file contents. len() -> number May also be invoked as `#contents'. Returns the exact length in bytes of the current file contents. sub(i,j) -> string Returns the characters between indices i and j, exactly like string.sub. gmatch(pattern) -> iterator Iterate over the file contents given the provided pattern. concat() -> contents Concatenate the given text to the end of the file contents. insert(i, data) -> contents Insert the given data **at** the provided index. Works like `table.insert'. Implementing file access in this way allows other benefits besides lower memory requirements. It also simplifies program construction because programs do not need to manage an internal buffer of file contents.