// let stdin = 0; // let stdout = 1; // let stderr = 2; fn print(msg: string) #[builtin(Print)] {} fn println(msg: string) { print(msg + "\n") } fn file_open(filename: string, mode: string) -> int #[builtin(FileOpen)] {} fn file_close(file: int) #[builtin(FileClose)] {} fn file_write_string(file: int, content: string) -> int #[builtin(FileWriteString)] {} fn file_read_to_string(file: int) -> string #[builtin(FileReadToString)] {} fn file_flush(file: int) #[builtin(FileFlush)] {} fn file_eof(file: int) -> bool #[builtin(FileEof)] {} fn main() { let file = file_open("test.txt", "w"); file_write_string(file, "hello world"); file_close(file); file = file_open("test.txt", "r"); let content = file_read_to_string(file); file_close(file); file_write_string(1, content + "\n"); file_flush(1); }