LEARN VOID / DATA & BEHAVIOR

Interfaces

Describe shared behavior with VOID’s structural interfaces.

Complete program for the synchronous entry adapter. The result below is the returned integer.

interfaces.voidDownload source
interface readable:
    func read() -> i32

struct fuel_tank:
    liters: i32

func (tank fuel_tank) read() -> i32:
    return tank.liters

func fuel_level(const source: readable) -> i32:
    return source.read()

func entry(liters: i32) -> i32:
    var tank = fuel_tank(liters = liters)
    return fuel_level(tank)
Input 5Expected result 5

Describe one required behavior

readable requires a no-argument read method returning i32. The fuel tank supplies that signature. Structural conformance needs no implements declaration.

Accept an interface view

fuel_level accepts the behavior rather than a specific tank type. Passing a tank with five liters returns 5. The interface view observes the same managed object; it does not create a separate tank.

Preserve readonly access

The parameter is const, and read only observes its receiver. A mutating method would still need appropriate authority. Interface conversion does not bypass visibility, exact signature or receiver-effect checks.