Add file operations as built-ins
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mars |
Triaged
|
Wishlist
|
Matt Giuca |
Bug Description
Mars currently implements two I/O operations, get_char and put_char, which deal with stdout and stdin respectively. Add four new built-ins which deal with arbitrary files:
fopen(filename :: Array(Int)) :: Int
fclose(handle :: Int) :: Int # 0-return
fget_char(handle :: Int) :: Int
fput_char(handle :: Int, char :: Int) :: Int # 0-return
The file handles are integers, and are arbitrary integers representing open files. It is an error to fclose, fget_char or fput_char an unopened file handle. Integers 0, 1 and 2 are reserved for stdin, stdout and stderr respectively, and are constants defined in prelude.
Also add new higher-level prelude functions, an 'f' version of print_char_list, print_string, print_value, get_line_list and get_line. Probably remove get_char and put_char as built-ins, and make them prelude functions which call fget_char and fput_char (so overall, we are really only adding 2 built-ins, and modifying 2).
This should be accompanied by a fix to bug #550735, adding command-line arguments so it is actually possible to specify filenames on the command line.
tags: |
added: library removed: builtins |
Changed in mars: | |
milestone: | none → 0.4 |
Changed in mars: | |
milestone: | 1.0 → 1.1 |