日本語

Advanced Features

Pattern Matching

match is used to perform branching on alge type values and extract parameters. (For alge types, see Values and Types)

alge Shape {
    Rect( real, real ),
    Circle( real ),
}
fn area( s:Shape ): real {
    match s {
        case .Rect( w, h ) { return w * h; }
        case .Circle( r ) { return r * r * 3.14; }
    }
}

Asynchronous Processing

This is an asynchronous processing feature available when transcompiling to the Go language.

class Task extend (__Runner) {
    pub fn run() __async mut {
        print( "Async Task" );
    }
}
let mut t = new Task();
__run( t, __lns.runMode.Sync, "task" );
__join( t );
Access to mutable external variables and __noasync functions is restricted from __async functions. To temporarily lift this restriction, use an __asyncLock block.

Glue Code

This is a feature that automatically generates Glue code for interconnecting with Lua's C API.

module External require "test.ext" glue 'prefix_' {
    pub static fn func(): int;
}

This generates bridge code for calling the C-side prefix_func function.