mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 00:44:27 +00:00
export fn name(...) is a C function by that name (numbers, bool, char, pointers in and out). --shared builds lib<name>.so / <name>.dll with no main. finch_module_on_fatal(handler) lets the host take runtime errors over (longjmp out) instead of the process exiting. tests/shared.sh: a C host loads one, calls it and survives an index error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
331 B
Text
22 lines
331 B
Text
import "host.h"
|
|
|
|
fn greet(str who) -> str {
|
|
return "hello " + who
|
|
}
|
|
|
|
export fn add(int a, int b) -> int {
|
|
return a + b
|
|
}
|
|
|
|
export fn hello(ptr[char] name) {
|
|
host_print(greet(str(name)))
|
|
}
|
|
|
|
export fn crash(int i) -> int {
|
|
xs := [1, 2, 3]
|
|
return xs[i]
|
|
}
|
|
|
|
export fn is_even(int n) -> bool {
|
|
return n % 2 == 0
|
|
}
|