Modules are known by their file: import button from ui/menu.fch and import ui/button are one module, two util.fch are two; min/max/abs/clamp win over C's int-only abs; completion after an import's other name; hover docs; engineers' guides

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GzNP6r8dg6WDxUVZy8wjL
This commit is contained in:
Nexoniarz 2026-10-29 09:52:04 +01:00
commit 3ba2dcd5d6
16 changed files with 152 additions and 18 deletions

View file

@ -1,5 +1,6 @@
// C unions (SDL_Event-style) and #defines that are expressions, strings or casts
import "cunion.h"
import "stdlib.h"
link "cunion.c"
fn main() {
@ -22,4 +23,5 @@ fn main() {
Tagged t
t.as.f = 0.5
print(t.as.f)
print(abs(-2.5), abs(-3), min(EV_KEY, 7)) // Finch's abs, not C's int-only one
}

View file

@ -4,3 +4,4 @@ motion 1.5 -2
true 32
32 2
0.5
2.5 3 7

View file

@ -0,0 +1,10 @@
// a module is its file: ui/menu's "import button" is this file's "import ui/button",
// and ui/util.fch and util.fch are two different modules
import ui/button
import ui/menu
import util
fn main() {
button.Button b = menu.first()
print(b.label, b.w, menu.whoami(), util.who())
}

View file

@ -0,0 +1 @@
menu 30 ui/util util

11
tests/new/ui/menu.fch Normal file
View file

@ -0,0 +1,11 @@
// for tests/new/modules_by_file.fch: its sibling, imported without the folder
import button
import util
fn first() -> button.Button {
return button.make("menu")
}
fn whoami() -> str {
return util.who()
}

4
tests/new/ui/util.fch Normal file
View file

@ -0,0 +1,4 @@
// for tests/new/modules_by_file.fch: a util.fch in a folder
fn who() -> str {
return "ui/util"
}

4
tests/new/util.fch Normal file
View file

@ -0,0 +1,4 @@
// for tests/new/modules_by_file.fch: the top-level util.fch
fn who() -> str {
return "util"
}