next up previous contents
Next: Int Up: Basic Classes Previous: Object   Contents

IO

The IO class provides the following methods for performing simple input and output operations:
out_string(x : String) : SELF_TYPE
out_int(x : Int) : SELF_TYPE
in_string() : String
in_int() : Int
The methods out_string and out_int print their argument, flush the standard output, and return their self parameter.

The interpreter changes every \t to a tab and eveyr \n to a newline in the argument x to out_string before emitting the resulting string.

The method in_string reads a string from the standard input, up to but not including a newline character. If an error occurs (for example, if end-of-file has been reached on the standard input stream), in_string returns "", the string of length 0. Note that while literal lexical string constants are limited to size 1024, strings generated by in_string (or String.concat, etc.) can be of arbitrary size.

The method in_int reads a single integer, which may be preceded by whitespace. Any characters following the integer, up to and including the next newline, are discarded by in_int. If an error occurs (for example, end-of-file or a malformed integer) then in_int returns 0.

A class can make use of the methods in the IO class by inheriting from IO. It is an error to redefine the IO class.