language · language ·

Extension functions

Mark the first parameter extension to let an ordinary function use readable value.Method(...) call syntax.

cpuextensionfunctionslanguageyeho

Use an extension when behavior conceptually belongs beside a type but you do not own or should not expand the type declaration.

Function(Type extension value, ...) -> ReturnType
value.Function(...)

Status: stable

Complete extension functions example

Use an extension when behavior conceptually belongs beside a type but you do not own or should not expand the type declaration.

cpu · language · type checked

thing Point
{
    int x
    int y
    Point(int x, int y) { this.x = x this.y = y }
}
Magnitude(Point extension value, int offset = 0) -> int
{
    return value.x + value.y + offset
}
Point point = Point(1, 5)
Console.Log(Text.From(point.Magnitude(offset: 7)))
project.mech
manifestVersion = "2"
package = "api.example.language__extension_functions"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"
Notes and source

extension is a binding mode on the first parameter.

The direct function remains explicit and testable even though call syntax reads like a method.

yeho/tests/compiler/kyber/legalized-call-forms/start.yh; parser_types.cpp parseParameters