Queue the pointer-length question, with the three examples it blocks

This commit is contained in:
Joseph Ferano 2026-09-13 14:51:31 +07:00
parent 68625a535e
commit 3e6886831d

26
NEXT.md
View File

@ -1,3 +1,29 @@
## Queued: a pointer from C needs a length before it can be indexed
**Sequenced after the generics lane**, which holds `lib/check.ml`.
`indexed` in `lib/check.ml` accepts `Array` and `Slice` only, so a `(Ptr T)` that came back from C is readable at
element 0 through `deref` and nowhere else. Confirmed empirically rather than inferred:
`(at (.recs (rl/get-font-default)) 0)` answers `(Ptr rl/Rectangle) cannot be indexed`.
**It blocks real work now**, which is why it moved from a note to a queue entry. Three upstream examples are
unportable — `text_rectangle_bounds` (walks `font.recs[i]` and `font.glyphs[i]`), `text_codepoints_loading`
(`LoadCodepoints` returns `int*`) and `textures_image_processing` (`LoadImageColors` returns `Color*`) — and the
first of those is the only *procedural* font example, so the whole hand-written `Font` surface has no example
caller. Every other text example needs a TTF on disk.
The problem is that C hands back a pointer and no length. Two shapes:
1. **`(slice-from-ptr p n)`** — the caller states the length and owns being right about it. Honest, one form, and
the unsafety is written at the site where somebody had to know the answer anyway. It is the same trust
`declare-c` already extends.
2. **A per-binding declaration naming which argument carries the count.** raylib's convention is an out-parameter
(`LoadCodepoints(text, &count)`), so the information usually *is* there. This makes the binding carry it once
instead of every call site repeating it, and it fits the existing `bindings` file. It does not cover
`font.recs`, where the count is a sibling *field* (`font.glyphCount`) rather than an argument.
They are not exclusive, and 2 does not cover every case, so 1 is probably the floor whatever else is built.
## Queued, decided by the author: generic structs and generic array lengths
**Sequenced after the core generics lane, not beside it.** Both change `Types.t`, which that lane is inside.