-
-
Notifications
You must be signed in to change notification settings - Fork 0
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.
| 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.
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.
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.
const and comptime fn use the evaluator with IO, environment, time, randomness, unsafe work,
and tasks denied. Effectful compile-time evaluation reports E7009.
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.
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.
- Modules And Imports
- Values, Bindings, And Blocks
- Types And Inference
- Records, Sums, And Tuples
- Functions Generics And Traits
- Pattern Language
- Control Flow And Patterns
- Iteration And Loops
- Failure And Propagation
- Numbers And Collections
- Sets Maps And Sequences
- Keyed Structures
- Trees And Hierarchies
- Standard Library
- Output Formatting And Testing
- Tasks And Scopes
- Compile-Time Evaluation
- Typed Macros
- References And Unsafe
- Worked Programs