Syntax Overview
Syntax Overview
Thagore uses Python-style indentation for blocks. Every block header ends with : and the body is indented with 2 spaces.
Key rules
- 2-space indentation — tabs are rejected, and indentation must be a multiple of 2 spaces
- No semicolons — each statement is one line
- Conditions require parentheses —
if (x > 0):andwhile (x > 0): - Comments use
# - File extension is
.tg
Minimal program
func main() -> i32: println("Hello, Thagore!") return 0Top-level forms
A source file contains top-level declarations only. There are no bare executable statements outside functions.
import std.math as math
const LIMIT: i32 = 10
struct Point: x: i32 y: i32
func distance(point: Point) -> i32: return math.abs(point.x) + math.abs(point.y)
func main() -> i32: return 0Syntax topics
- Print & Output —
print,println, output to stdout and stderr - Variables & let —
letdeclarations, type inference, reassignment - Functions —
func, parameters, return types - Control Flow —
if/else,while,for,break,continue - Structs & impl — struct definitions and methods
- FFI & Import —
import,extern func - Advanced Features —
intent,flow, generics - Reading Input — reading from stdin via
std.io