Skip to main content
Reference for every callable form in Kairo v0.1: func, instance methods, type func, init, async func, and await, plus local bindings and return.

func

Declares a function. Syntax
Rules
  • At module scope, func is a free function.
  • Inside a value, object, or contract, func is an instance method or requirement.
  • Omitting the return type means the function returns no value.
  • No overload resolution: names must be unique in their scope.
  • No default parameter values in v0.1.
Example

Instance method

A func declared inside a type. Rules
  • Value methods have an immutable this.
  • Object methods have an identity-bearing this and may mutate var members.
  • Contract methods are requirements: signature only, no body.
  • Extension methods are deferred.
Example

type func

Declares a function owned by the type itself. Syntax
Rules
  • Must be declared inside a value or object.
  • Has no this receiver.
  • Called through the type name: TypeName.functionName(...).
  • Kairo does not use static in v0.1.
Example

init

Initializes an object. Syntax
Rules
  • Only allowed inside object. Values have no init.
  • Exactly one primary init per object in v0.1.
  • Required immutable members must be assigned before init completes.
  • Cannot return a value.
  • Constructor overloading, constructor delegation, and lifecycle hooks are deferred.
Example

async func

Declares a function that may suspend. Syntax
Rules
  • May appear on free functions, instance methods, type func, and contract requirements.
  • Not allowed on init or type declarations.
  • The language shape is frozen for v0.1; the async runtime is deferred.
Example

await

Suspends the current async function until the awaited call completes. Syntax
Rules
  • Only valid inside async func.
  • Does not unwrap Result<T, E>.
  • Does not create hidden detached background work.
  • Between suspension points, code runs in program order.
Example

Local bindings

let

  • Immutable binding.
  • Type inference is supported when the initializer type is obvious.

var

  • Mutable binding.
  • Local var requires an explicit type in v0.1.

this

References the current instance receiver. Only valid inside instance methods and init. Not available in free functions or type func.

return

  • Exits the current callable.
  • Returned expression must be assignment-compatible with the declared return type.
  • Functions with no declared return type must not return a value.

Functions (language guide)

Higher-level guide to callables.

Operators reference

Operators, control flow, and match expressions.