Skip to content

Language Surface

Chris Michael edited this page Sep 2, 2026 · 3 revisions

Pudu

Language Surface

module Name

import Std.Module as Alias

export fn main() -> Int { 0 }

Status: lexer, parser, resolver, type checker, formatter, interpreter, REPL, and LSP share this surface. The interpreter is the current execution target.

Declarations

Declaration Shape
Constant const LIMIT = 10
Function fn add(a: Int, b: Int) -> Int { a + b }
Async function async fn read() -> Result[Str, Str] { ... }
Compile-time function comptime fn square(n: Int) -> Int { n * n }
Record type type Point = { x: Int, y: Int }
Sum type `type Choice[T] = One(T)
Type alias type Handler = fn(Str) -> Result[Int, Str]
Trait trait Named { fn name(self: &Self) -> Str }
Implementation impl Named for User { ... }
Typed macro macro twice(value: expr) = value + value

export makes a top-level declaration visible to importing modules. Top-level executable statements are not admitted.

Expressions

Pudu is expression-oriented. Blocks, if, match, and loop can produce values. Evaluation is strict and left-to-right. Boolean && and || short-circuit.

let label = if count == 0 { "empty" } else { "ready" }

A block yields its final unterminated expression. A fallthrough block without one yields (). A block ending directly in return, break, or continue has type Never.

Bindings

let name = "Pudu"
var count = 0
count = count + 1

let is immutable. var is mutable. Binding initializers are evaluated before the new name enters scope.

Compile-time evaluation

const and comptime fn use the evaluator with IO, environment, time, randomness, unsafe work, and tasks denied. Effectful compile-time evaluation reports E7009.

Macros

Macros accept typed syntax parameters: expr, ident, or block. A call uses name!(...). Expansion is hygienic and bounded. Expanded nodes carry the macro call span, so diagnostics point to the invocation; a call-site/definition-site provenance chain is not implemented. Macro repetition syntax is not defined.

Entry points

export fn main() or export async fn main() is the program entry. Async main is the route into the interpreter's deterministic task-tree model. Native compilation and concurrent scheduling are not available.

Related

Clone this wiki locally