Tya v0.57 Specification

Status: shipped. The tya version constant is 0.57.0. v0.57 introduces the embed statement so files can be baked into a compiled tya binary at build time. The rest of the language surface is unchanged from v0.56.

Theme

Tya programs are compiled to a self-contained C executable. Until v0.57 every asset (HTML / CSS / images / config) had to ship as a separate file beside the binary. v0.57 adds a build-time embed form that turns one or more files into in-binary constants:

This is the foundation for “single-binary distribution”: a static site or small game can ultimately ship as a single tya binary, once a matching HTTP / graphics stdlib lands in a follow-up Epic.

Syntax

embed "assets/logo.png" as logo            # single file → bytes
embed "static/**" as assets                # recursive glob → dict
embed "assets/*.png" as sprites            # single-level glob → dict

Semantics

Single-file form

embed "data.txt" as payload
print(bytes_text(payload))

The bytes are read at codegen time and emitted into the generated C as a tya_bytes_lit((const char*)(unsigned char[]){…}, N) initializer. The binding is registered as a top-level value so the runtime GC can root it like any other global.

Glob form

embed "static/**" as assets
for path, _ of assets
  print(path)

The codegen walks the filesystem (recursively when ** is present, single-level for *) and builds a tya_dict((TyaDictEntry[]){…}, N) initializer. Dictionary keys are the matching files’ paths relative to the source file’s directory, normalized to /-separated form even on Windows hosts. Insertion order is deterministic (sorted alphabetically).

A glob that matches zero files raises TYA-E0611 at codegen.

Type

embed always produces bytes (single) or dict<string, bytes> (glob). There is no as bytes / as text modifier and no extension-based auto-detection. When a string value is needed, call bytes_text (or tya_bytes_text in the runtime) explicitly:

embed "page.html" as raw
html = bytes_text(raw)

Path resolution

Diagnostics

Code Trigger
TYA-E0610 embed source file not found at codegen time
TYA-E0611 embed glob matched zero files

Both codes are codegen-band diagnostics, so the failure surfaces through tya run, tya build, and tya emit-c, not through tya check (which stops before codegen).

Implementation notes

Scope-out (v0.58+)