From 1b6ac779a87e9603c1372dd13466f276abf22141 Mon Sep 17 00:00:00 2001 From: alex-eg Date: Fri, 9 Oct 2026 18:22:41 +0300 Subject: [PATCH] import only the modules each unit uses An import brings the types and constants its interface needs now (sex#58): a module pub-imports what its pub forms hold, and sexc refuses one that does not. Every unit had imported its whole dependency chain in order to make up for it. worldgen also pub-imports json, whose cJSON.h its pub fns take pointers into; a type only C knows is not something sexc can check. Co-Authored-By: Claude Opus 5.5 --- src/hover.sex | 8 -------- src/ores.sex | 5 ----- src/rivers.sex | 5 ----- src/search.sex | 8 -------- src/settings.sex | 7 ------- src/strata.sex | 7 ------- src/terra.sex | 5 ----- src/tiles.sex | 6 ------ src/verify.sex | 7 ------- src/viewer.sex | 7 ------- src/vsmv.sex | 11 ----------- src/worldgen.sex | 4 ++-- 12 files changed, 2 insertions(+), 78 deletions(-) diff --git a/src/hover.sex b/src/hover.sex index fca6158..06ac222 100644 --- a/src/hover.sex +++ b/src/hover.sex @@ -9,16 +9,8 @@ (pub include pthread.h) (include stdio.h stdlib.h string.h math.h) -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. (import maps) -(import lcg) -(import noise) -(import shape) -(import json) (pub import worldgen) -(import fastnoise) (pub import rivers) (import terra) (import strata) diff --git a/src/ores.sex b/src/ores.sex index 45445be..8c563c5 100644 --- a/src/ores.sex +++ b/src/ores.sex @@ -20,9 +20,6 @@ ;;; can't be read at all without the deposits. (include stdio.h stdlib.h string.h math.h dirent.h) -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. (import cs) (import maps) (pub import lcg) @@ -30,8 +27,6 @@ (import shape) (import json) (pub import worldgen) -(import fastnoise) -(import rivers) (import terra) (import strata) diff --git a/src/rivers.sex b/src/rivers.sex index 2ae61f2..3f759cf 100644 --- a/src/rivers.sex +++ b/src/rivers.sex @@ -10,12 +10,7 @@ ;;; every RNG call is the mod's: it is what the layout depends on. (include stdlib.h string.h math.h) -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. -(import maps) (pub import lcg) -(import noise) (import shape) (import json) (import worldgen) diff --git a/src/search.sex b/src/search.sex index 67e82b8..a052ab5 100644 --- a/src/search.sex +++ b/src/search.sex @@ -11,16 +11,8 @@ (pub include pthread.h) (include stdio.h stdlib.h string.h math.h) -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. (import maps) -(import lcg) -(import noise) -(import shape) -(import json) (pub import worldgen) -(import fastnoise) (pub import rivers) (import terra) (import strata) diff --git a/src/settings.sex b/src/settings.sex index 8114857..1c81b1c 100644 --- a/src/settings.sex +++ b/src/settings.sex @@ -3,15 +3,8 @@ ;;; has the seed as typed and the world config as strings. (include stdio.h stdlib.h string.h) -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. (import cs) (import json) -(import maps) -(import lcg) -(import noise) -(import shape) (import save) (pub import worldgen) diff --git a/src/strata.sex b/src/strata.sex index ebd00dd..89c8691 100644 --- a/src/strata.sex +++ b/src/strata.sex @@ -10,17 +10,10 @@ ;;; if it were rock, as the game's prospecting assumes too. (include stdio.h stdlib.h string.h math.h) -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. (pub import maps) -(import lcg) (import noise) -(import shape) (import json) (import worldgen) -(import fastnoise) -(import rivers) (pub import terra) (pub define MAX-ROCKS 32) diff --git a/src/terra.sex b/src/terra.sex index 9fe21b2..e1c9e7d 100644 --- a/src/terra.sex +++ b/src/terra.sex @@ -10,14 +10,9 @@ ;;; certainly air above. (include stdio.h stdlib.h string.h math.h) -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. (pub import maps) -(import lcg) (import noise) (import shape) -(import json) (pub import worldgen) (pub import fastnoise) (pub import rivers) diff --git a/src/tiles.sex b/src/tiles.sex index 16d464a..514d018 100644 --- a/src/tiles.sex +++ b/src/tiles.sex @@ -13,13 +13,7 @@ (pub include pthread.h SDL3/SDL.h) (include stdio.h stdlib.h string.h math.h) -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. -(import json) (import maps) -(import lcg) -(import noise) (pub import shape) (pub import worldgen) (import fastnoise) diff --git a/src/verify.sex b/src/verify.sex index c867586..f3cfbc4 100644 --- a/src/verify.sex +++ b/src/verify.sex @@ -3,17 +3,10 @@ ;;; map matches to the pixel, padding included. (include stdio.h stdlib.h string.h math.h time.h) -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. (import maps) -(import lcg) -(import noise) -(import json) (import shape) (import save) (import worldgen) -(import fastnoise) (pub import rivers) (import terra) (import strata) diff --git a/src/viewer.sex b/src/viewer.sex index 6ad350c..d7b3792 100644 --- a/src/viewer.sex +++ b/src/viewer.sex @@ -12,17 +12,10 @@ ;;; quits, which is how the viewer is checked without looking at it. (include stdio.h stdlib.h string.h math.h unistd.h "nk.h" "stb_image_write.h") -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. (import cs) -(import json) (import maps) -(import lcg) (import noise) -(import shape) (import worldgen) -(import fastnoise) (import rivers) (import terra) (import strata) diff --git a/src/vsmv.sex b/src/vsmv.sex index 0aab536..243021b 100644 --- a/src/vsmv.sex +++ b/src/vsmv.sex @@ -2,23 +2,12 @@ ;;; against a saved world and dumps what either side produced. (include stdio.h string.h) -;; An import brings in a module's own public forms but not the types -;; they mention, so dependencies come first. -;; TODO sex#58: import only the modules used here once an import brings -;; the types its interface needs; until then, every dependency, in -;; dependency order. (import cs) (import json) -(import maps) -(import lcg) -(import noise) -(import shape) (import save) (import dump) (import worldgen) -(import fastnoise) (import rivers) -(import terra) (import strata) (import settings) (import ores) diff --git a/src/worldgen.sex b/src/worldgen.sex index 1d7fb57..31632ce 100644 --- a/src/worldgen.sex +++ b/src/worldgen.sex @@ -4,10 +4,10 @@ ;;; the worldgen assets and the region's coordinates. (include stdio.h stdlib.h string.h math.h) -(import maps) +(pub import maps) (pub import lcg) (import noise) -(import json) +(pub import json) (pub import shape) (pub define MAX-PROVINCES 32)