Documentation channel: current development main at compiler checkpoint 1d7e15e. The latest tagged release is v0.0.3; pages identify APIs that are not yet released.

Streams

Strut keeps the useful C++ stream model while using clearer standard stream names: in, out, and err. File streams are deterministic resources and support both construction with a path and explicit .open()/.close().

Standard output

out << "hello, world!" << endl;

Standard error

err << "could not open file" << endl;

Standard input

string name;
in >> name;

Output files

ofstream ofs("report.txt");
ofs << "hello" << endl;
ofs.close();

Open later

ofstream ofs;
ofs.open("report.txt");
ofs << "ready" << endl;
ofs.close();

Input files

ifstream ifs("data.txt");
string value;
ifs >> value;
ifs.close();

String streams

sstream ss;
ss << "count=" << count;
text := ss.str();

Convenience functions

Streams do not replace the short common-case helpers.

print("hello");
name := input();
input(name);

User-defined stream insertion

<< and >> use Strut's ordinary operator-overload machinery. A type can therefore define how it is written to a stream without adding special formatting hooks.

struct Point {
    int x;
}

operator <<(ostream& stream, Point& const point) -> ostream& {
    stream << point.x;
    return stream;
}

File lifetime

File streams close their underlying handle when the object is destroyed, but explicit .close() is useful when the program needs errors reported immediately or wants to release the file before the surrounding scope ends.

Whole-file I/O

For the common case where the entire file is wanted at once, the filesystem module provides bulk operations that size the file, allocate the destination once, and perform a direct read or write.

include <filesystem>;

string text := read_file("config.txt");
write_file("copy.txt", text);
append_file("copy.txt", "\nmore");

bytes raw := read_bytes("image.bin");
write_file("image-copy.bin", raw);

ifstream.read_all() uses the same size-aware bulk-read strategy for regular files. Stream APIs remain the right choice for incremental, token-by-token, or line-by-line processing.