mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 16:54:25 +00:00
- finch.toml: name, entry, paths, include, links, libdirs, cflags, ldflags, and [target.windows] etc.;
finch run / build / test with no file use its entry
- import thread: spawn, join, mutex, cpus; atomic_add/sub/load/store/swap/cas built in
- finch fmt [--check]: indentation by { }, trailing spaces, empty lines; also as LSP formatting
- link "x.cpp" (or in finch.toml): built with the C++ compiler, which then links (FINCH_CXX)
- #define RAYWHITE (Color){ 245, 245, 245, 255 } imports as a Color
- push(body) where push takes ptr[Body]: the same as push(addr(body))
- --target android (NDK clang from ANDROID_NDK_HOME, -llog)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GzNP6r8dg6WDxUVZy8wjL
23 lines
436 B
Text
23 lines
436 B
Text
struct Body {
|
|
float x
|
|
float y
|
|
}
|
|
|
|
fn push(ptr[Body] b, float dx) {
|
|
b.x += dx
|
|
}
|
|
|
|
fn Body.moved(float dx) -> Body {
|
|
return Body(x: self.x + dx, y: self.y)
|
|
}
|
|
|
|
fn main() {
|
|
b := Body(x: 1.0, y: 2.0)
|
|
push(b, 0.5) // the same as push(addr(b), 0.5)
|
|
push(addr(b), 0.5)
|
|
print(b.x)
|
|
p := addr(b)
|
|
push(p, 1.0) // already a ptr: as it is
|
|
print(b.x)
|
|
print(b.moved(1.0).x)
|
|
}
|