Spec Update: Batch 06 — Functions
Date: 2026-04-16 Plans Referenced: Plan 035 (static methods), Plan 048 (generics), Plan 060 (closures), Plan 088 (param modes), Plan 122 (ownership), Plan 163 (pub/mut) Source Files: ast/fun.rs (Fn, Param, ParamMode, Closure), ast.rsSections Updated: Functions (Section 9) — major rewrite
Old Content
Old Functions section had 4 subsections:
- Function Definition (basic syntax)
- Function Calls
- Lambda Functions (using old
|a int, b int| (int) exprsyntax) - Parameter Passing Modes (using
ref/mut ref/moveprefix syntax)
Issues:
- Used
println()instead ofprint() - Lambda syntax was wrong (used
|...|instead of=>) - Parameter modes used prefix keywords (
ref,mut ref,move) - No generic functions, no static methods, no pub visibility, no annotations
New Content
Function Definition
- Fixed to use
print()instead ofprintln() - Noted space-separated return type (no
->)
Generic Functions (Plan 048)
fn identity<T>(x T) T { x }- Type constraints via
haskeyword
Parameter Modes (Plan 088)
- Updated to
ParamModeenum: View (default), Mut, Move - Deprecated: Copy, Take
- No more
ref/mut refprefix syntax
Static Methods (Plan 035)
static fn new()syntaxselfkeyword for instance methods
Public Visibility (Plan 163)
pub fn,pub type,pub enum,pub speckeyword prefix
Closures (Plan 060)
- Updated to
(a, b) => exprsyntax (was|...|) - Single-param:
x => expr - Capture semantics documented
Function Annotations
#[vm],#[c],#[c, vm]
Function Kinds
- 5 kinds: Function, Lambda, Method, CFunction, VmFunction
Default Parameters
fn greet(name str, greeting str = "Hello") str
Mutable Methods (Plan 163)
mut fn increment()syntax
Notes
- Old lambda syntax
|a, b| expris NOT used in Auto. Use(a, b) => expr. selfis implicit in methods (no need to declare as parameter)FnKind::VmFunctionis for functions implemented via VM registry, not declared by users