Tya v0.18 Specification

This document is the specification for Tya v0.18 after v0.17 import aliases and module loading rules.

Theme

Tya v0.18 is about expanding module-style standard APIs for strings, arrays, and dictionaries.

Tya keeps built-in values lightweight. String, array, and dictionary operations are written as module functions such as string.trim(value), array.join(values, separator), and dict.has(value, key).

v0.18 expands those module APIs instead of adding built-in value methods or built-in collection classes.

Goals

Included in v0.18

v0.18 includes all v0.17 behavior and adds:

Not Included in v0.18

v0.18 does not include:

Built-ins

Tya v0.18 keeps global built-in functions small and Go-like.

The only functions available without import are:

print writes a value. println writes a value followed by a newline.

len(value) returns the length of a string, array, or dictionary. It remains a global built-in because length checks are common in control-flow code.

panic(value) stops the program with a fatal error. panic is not caught by try or catch.

Other standard operations are not global built-ins. They live in explicit standard modules such as string, array, and dict.

try, catch, and raise are language syntax, not built-in functions. try and catch handle structured errors raised with raise; they do not catch panic.

String Module

The string module contains functions that operate on string values.

Existing string helpers remain available. v0.18 standardizes this practical surface:

Examples:

import string

print string.trim("  tya  ")
print string.contains("hello", "ell")
print string.join(["a", "b", "c"], ":")
print string.lines("a\nb")
print string.upcase("tya")

string.join(values, separator) joins an array of values after converting each element with the same conversion behavior as to_string.

string.lines(value) splits a string into lines without keeping line-ending characters.

Array Module

The array module contains functions that operate on array values.

Existing array helpers remain available. v0.18 standardizes this practical surface:

Examples:

import array

values = ["a", "b", "c"]

print array.first(values)
print array.last(values)
print array.slice(values, 0, 2)
print array.reverse(values)
print array.join(values, ":")

array.push(values, value) mutates values and returns the mutated array.

array.pop(values) mutates values and returns the removed value.

array.slice(values, start, end) returns a new array from start inclusive to end exclusive. Negative indexes are not part of v0.18.

array.reverse(values) returns a new reversed array and does not mutate the input array.

Dict Module

The dict module contains functions that operate on dictionary values.

Existing dict helpers remain available. v0.18 standardizes this practical surface:

Examples:

import dict

user = {"name": "komagata"}

print dict.has(user, "name")
print dict.get(user, "name")
print dict.get(user, "email", "none")
print dict.keys(user)

dict.get(value, key) returns nil when the key is missing.

dict.get(value, key, default) returns default when the key is missing.

dict.set(value, key, item) mutates value and returns the mutated dictionary.

dict.delete(value, key) mutates value and returns the deleted value, or nil when the key is missing.

dict.merge(left, right) returns a new dictionary. Keys from right override keys from left.

The old dictionary module name is not kept as a compatibility alias. v0.18 standardizes on dict only.

API Style

v0.18 keeps module function style as the standard style for built-in value operations.

import string
import array
import dict

name = string.trim("  tya  ")
joined = array.join(["a", "b"], ":")
exists = dict.has({"name": name}, "name")

The following method-call style is not part of v0.18:

"  tya  ".trim()
["a", "b"].join(":")
{"name": "tya"}.has("name")

This keeps the object model smaller and keeps collection APIs explicit.

Argument Errors

Module functions should report source-oriented errors for invalid argument counts and invalid argument kinds.

array.first("not array")
string.split("a,b,c")
dict.keys(["not", "dictionary"])

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

Diagnostics

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

Diagnostics should mention the module name and function name when available.