COMPLETE SYNTAX & ARCHITECTURE SPECIFICATION

Language Reference Manual

TezzNative combines the clean clarity of Python with bare-metal C performance, native tensors, coroutines, and zero garbage collection pauses.

1. Type System

TezzNative is statically typed with strong compile-time inference and zero runtime type overhead. Built-in types map directly to hardware registers.

// Primitive scalar types
let a: int = 42              // 64-bit signed integer (i64)
let b: float = 3.14159       // 64-bit double precision float (f64)
let c: char = 'Z'            // 8-bit unsigned character
let s: str = "TezzNative"   // Null-terminated UTF-8 string slice

// Fixed SIMD & Tensor Vector Types
typedef [float; 4] Vec4f     // 128-bit SSE vector (4 x f32)
typedef [float; 8] Vec8f     // 256-bit AVX2 vector (8 x f32)
typedef [int; 8]   Vec8i     // 256-bit integer vector (8 x i32)

2. Variables, Constants & Defer

Variables are declared with let. The defer keyword guarantees that resources (files, sockets, memory) are closed automatically at scope exit without garbage collection pauses.

import "io"

fn process_file(path:str) -> int:
  let h = io.open_file(path, "r")
  if h == 0: ret 0 - 1

  defer io.close_file(h)  // Executed automatically when function returns
  let content = io.read_all(h)
  say "File size:", len(content)
  ret 0

3. Control Flow

Clean Pythonic indentation-based blocks with if / elif / else, while, for loops, and pattern matching.

let count: int = 0
while count < 10:
  if count % 2 == 0:
    say count, "is even"
  else:
    say count, "is odd"
  count = count + 1

4. Functions & Tail-Call Optimization (TCO)

Functions compile to standard x86-64 / ARM64 calling conventions with register-passed arguments (`RCX, RDX, R8, R9` on Win64). Tail-recursive functions are automatically optimized into loops without stack growth.

// Guaranteed Tail-Call Optimized Fibonacci
fn fib_tail(n:int, a:int, b:int) -> int:
  if n == 0: ret a
  if n == 1: ret b
  ret fib_tail(n - 1, b, a + b)  // Lowered to zero-overhead JMP

5. Structs & Automatic Pointer Dereferencing

Structs lay out fields continuously in memory without padding surprises. Dot access works seamlessly on both values (obj.field) and pointers (ptr.field).

struct TensorShape:
  ndim: int
  dims: [int; 4]
  total_elements: int

fn create_matrix(rows:int, cols:int) -> TensorShape:
  let shape: TensorShape
  shape.ndim = 2
  shape.dims[0] = rows
  shape.dims[1] = cols
  shape.total_elements = rows * cols
  ret shape

6. Native Async / Await Coroutines

TezzNative coroutines are true non-blocking lightweight tasks scheduled across native I/O completion ports (IOCP on Windows, epoll on Linux).

import "task"
import "net"

async fn fetch_api_data(endpoint:str) -> int:
  let client = net.http_client()
  defer client.close()
  let resp = client.get(endpoint)
  ret resp.status_code

fn main() -> int:
  let t1 = task.spawn_arg(fetch_api_data, "https://api.tezzcorp.com/v1/metrics")
  let status: int = await t1
  say "HTTP Response:", status
  ret 0

7. Native Deep Learning Tensors & Autograd

First-class tensor algebra with infix @ for matrix multiplications, SIMD AVX-512 kernels, and CUDA GPU dispatch via tzgpu.

import "tztensor"
import "tzgpu"

fn main() -> int:
  // Initialize 2D tensors [Batch x Hidden]
  let A = tztensor.zeros_2d(128, 512)
  let W = tztensor.xavier_2d(512, 1024)

  // Ultra-fast Hardware GEMM (dispatched to CUDA GPU if available)
  let C = tztensor.matmul(A, W)
  say "Computed output tensor shape:", C.rows, "x", C.cols
  ret 0

8. Native Audio Subsystem (TTS & STT)

Zero-dependency native speech synthesis and microphone audio capture powered by tzgui.dll and Windows SAPI / WinMM drivers.

import "tts"
import "stt"

fn main() -> int:
  // 1. Crystal-clear Text-to-Speech
  let eng = tts.tts_new()
  tts.tts_speak(eng, "Welcome to TezzNative voice assistant.")
  tts.tts_free(eng)

  // 2. Microphone Capture & Whisper Mel-Spectrogram Extraction
  let stt_eng = stt.stt_new()
  let transcription = stt.stt_from_mic(stt_eng, 3000) // 3000ms audio
  say "Transcribed text:", transcription
  stt.stt_free(stt_eng)
  ret 0

9. High-Performance GUI Framework

Native 60 FPS retained & immediate-mode GUI with anti-aliased text, rounded rectangles, wallpaper rendering, and mouse event dispatching.

import "tezzui"

fn main() -> int:
  tezzui.window("TezzNative Desktop App", 800, 600)
  while tezzui.running():
    tezzui.fill(0x080B11)  // Deep Dark Background
    tezzui.fill_rounded(50, 50, 700, 100, 16, 0x1E2842)
    tezzui.text(80, 85, "Hello TezzNative Native GUI!", 0xFF9933)
    tezzui.present()
  ret 0

10. Unsafe Blocks & Low-Level Hardware Access

TezzNative enforces safe bounds on standard code. When bare-metal pointer arithmetic or OS kernel interaction is needed, explicit unsafe: blocks isolate raw pointers.

fn peek_raw_byte(addr:int) -> int:
  let byte_val: int = 0
  unsafe:
    let ptr:*char = addr as *char
    byte_val = ptr[0] as int
  ret byte_val