Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new public Pathname C API exposes mutable char* string accessors (*_value_cstr / *_like_value_cstr), which conflicts with immutability expectations and String’s const char* convention, and should be corrected before landing.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces a first-class Pathname abstraction (relative/absolute) with normalization, reader literal syntax (#p / #P), filesystem predicates, and a PathnameStat snapshot type, then updates core/module I/O entry points and tests to accept Pathname objects where strings were previously required.
Changes:
- Add
Pathname,RelativePathname,AbsolutePathname, andPathnameStatcore classes (normalization, printing, predicates, stat/lstat). - Extend the reader with a
#p"..."/#P"..."dispatch macro literal that reads to a normalized Pathname. - Update file/path-taking primitives in the VM and selected modules (os/zlib/ini, Stream/String/ByteVector/RandomAccessFile) to accept “pathname-like” arguments.
File summaries
| File | Description |
|---|---|
| tests/reader_test.c | Adds reader-level tests for #p/#P pathname literals, normalization, printing, and round-tripping. |
| tests/eval-objects.lt | Adds language-level Pathname/PathnameStat behavior tests (constructors, normalization, /, parent, stat predicates). |
| tests/eval-loading-control.lt | Updates loading expectations to treat ListTalk:OS:Stat as an alias of PathnameStat. |
| tests/c_api_test.c | Adds C API tests covering pathname normalization, UTF-8 preservation, append/parent/rootedAt, and stat helpers. |
| src/vm/reader.c | Implements pathname dispatch macro literal parsing for #p/#P. |
| src/vm/base_env/primitives.c | Allows read-file-as-data to accept Pathname or String inputs. |
| src/vm/base_env/base_env.c | Registers new core classes in the native class bindings list. |
| src/modules/zlib.c | Accepts pathname-like values for gzip open primitives by converting to String. |
| src/modules/os.c | Removes module-local Stat implementation and binds Stat to core PathnameStat; updates path args to pathname-like. |
| src/modules/ini.c | Accepts pathname-like values for INI file loading APIs. |
| src/classes/String.c | Updates file read/write primitives to accept pathname-like filenames. |
| src/classes/Stream.c | Updates stream filename argument parsing to accept pathname-like values. |
| src/classes/RandomAccessFile.c | Updates constructor to accept pathname-like filenames. |
| src/classes/Pathname.c | New implementation of Pathname and PathnameStat classes + C helpers. |
| src/classes/ByteVector.c | Updates file read/write primitives to accept pathname-like filenames. |
| meson.build | Adds src/classes/Pathname.c to the VM library build. |
| ListTalk/ListTalk.h | Exposes Pathname in the umbrella header. |
| ListTalk/classes/Pathname.h | New public header for Pathname/PathnameStat C API. |
Review details
- Files reviewed: 18/18 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| LT_String* LT_Pathname_as_string(LT_Pathname* pathname); | ||
| char* LT_Pathname_value_cstr(LT_Pathname* pathname); | ||
| int LT_Pathname_absolute_p(LT_Pathname* pathname); |
| LT_PathnameStat* LT_Pathname_lstat(LT_Pathname* pathname); | ||
| char* LT_Pathname_like_value_cstr(LT_Value value); | ||
| LT_String* LT_Pathname_like_as_string(LT_Value value); |
| if (expect(LT_AbsolutePathname_p(absolute), | ||
| "#p absolute literal dispatches to AbsolutePathname")){ |
There was a problem hiding this comment.
🔵 Needs a closer look
The new tests currently rely on backend/working-directory-specific files (e.g., build.ninja), making them brittle across build configurations and likely to fail in some environments.
Review details
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
tests/c_api_test.c:3684
- Using
build.ninjaas the “known existing file” makes this test depend on Meson’s Ninja backend and the test working directory. Using__FILE__is a more stable way to reference an existing regular file when running the C tests.
tests/eval-objects.lt:1640 - This test hard-codes
build.ninjaas the “existing regular file”, which is specific to Meson’s Ninja backend and can fail on other backends (or when the tests run from a different working directory). A more robust approach is to create a temporary file within the test and then run the file-kind/stat checks against that path.
- Files reviewed: 18/18 changed files
- Comments generated: 0 new
- Review effort level: Lite
No description provided.