Add file operations as built-ins

Bug #595762 reported by Matt Giuca
6
This bug affects 1 person
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: library
Matt Giuca (mgiuca)
tags: added: library
removed: builtins
Matt Giuca (mgiuca)
Changed in mars:
milestone: none → 0.4
Matt Giuca (mgiuca)
Changed in mars:
milestone: 1.0 → 1.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.