Created 2022-12-04 Updated 2022-12-27
ARRAYS:
let buf : [1024]u8 = [0..];
assert(len(buf) == 1024);
FOR LOOPS:
for (true) { ... };
for (let i = 0z; i < 10 ; i += 1) { ... };
let i = 0z;
for (i< 10; i+= 1) { ... };
SIGNALS:
use unix::signal;
Ctl-C ignoring:
unix::signal::block(unix::signal::SIGINT); // ignore Ctl-C
Ctl-C capturing:
use unix::signal;
use fmt;
use time;
let quit = false;
fn myhandler(sig: int, info: *unix::signal::siginfo, ucontext: *void) void = {
fmt::printf("myhandler called. I will now exit\n")!;
quit = true;
};
export fn main() void = {
fmt::printf("Type Ctl-C to exit this program\n")!;
defer fmt::printf("defer'd main message\n")!; // this will be output
unix::signal::handle(unix::signal::SIGINT, &myhandler);
for(!quit) { time::sleep(10); };
};
MAIN:
libraries: extended (compress, redis, json, xml, png, linux, etc.)
MISC: