Tya v0.21 Specification

This document is the specification for Tya v0.21 after v0.20 standard attached math and path modules.

Theme

Tya v0.21 adds native-backed standard library modules for file and process access.

v0.21 introduces the smallest native-backed stdlib surface: file and os. These modules expose external system operations through explicit imports and module functions.

Goals

Included in v0.21

v0.21 includes all v0.20 behavior and adds:

Not Included in v0.21

v0.21 does not include:

Native-backed Stdlib Rules

Native-backed stdlib APIs are exposed only as module functions.

import file
import os

They are not available without import.

Native-backed operation failures raise structured errors. They do not call panic.

import file

try
  text = file.read("missing.txt")
  println text
catch err
  println err

try and catch can handle native-backed operation failures because they are raised errors.

file

The file module contains basic whole-file text helpers.

Functions:

Examples:

import file

if file.exists?("memo.txt")
  text = file.read("memo.txt")
  println text

file.write("out.txt", "hello")

file.read(path) reads the entire file and returns it as a string.

file.write(path, text) writes text to path and returns nil on success.

file.exists?(path) returns true when the path exists and false when it does not exist. If existence cannot be determined, it raises an error.

All file functions require string path arguments. file.write(path, text) also requires string text.

file is text-oriented in v0.21. Binary IO is not part of this version.

os

The os module contains basic process-environment helpers.

Functions:

Examples:

import os

args = os.args()
home = os.env("HOME")

if len(args) == 0
  os.exit(1)

os.args() returns the command-line arguments as an array of strings.

os.env(name) returns the environment variable value as a string. It returns nil when the variable is not present.

os.exit(code) exits the process with code.

os.env(name) requires a string name.

os.exit(code) requires an integer code.

Existing Global Built-ins

v0.21 adds file.* and os.* as the preferred APIs for file and process operations.

Existing global IO/process built-ins remain available for compatibility in v0.21. Their deprecation or removal is a later-version decision.

v0.21 does not add any new global built-ins.

Diagnostics

v0.21 implementations should report source-oriented errors for:

Diagnostics should mention the module name, function name, expected argument shape, and actual value kind when available.