Conversation
⏺ The implementation is complete. Here's what was added:
New functions in ffi:libedit:
| Word | Stack Effect | Description |
|---------------|-------------------|--------------------------------------|
| read-history | ( String -- Int ) | Load history from file (0 = success) |
| write-history | ( String -- Int ) | Save history to file (0 = success) |
Files changed:
- crates/compiler/ffi/libedit.toml - Added the two new function bindings
- docs/FFI_GUIDE.md - Updated documentation with new functions and persistent history example
Usage example:
include ffi:libedit
: main ( -- Int )
"~/.seqlisp_history" read-history drop # Load on startup
run-repl
"~/.seqlisp_history" write-history drop # Save on exit
0
;
Pull Request Review: REPL HistoryThank you for this contribution! I've reviewed the implementation and have identified both strengths and critical issues. Strengths
CRITICAL ISSUE: Wrong API for libeditThe read_history and write_history functions are from GNU readline, NOT libedit. The ProblemLibedit (BSD) and GNU readline (GPL) have different APIs for history management:
These functions will FAIL TO LINK on systems using pure libedit (macOS, BSDs) because the symbols read_history and write_history don't exist in libedit. The comment in libedit.toml:23-24 correctly notes that function names match GNU readline's API for readline and add_history, but this is NOT true for read_history/write_history. Impact
SolutionsOption A: Use readline compatibility layer (document this requirement) Other Issues1. Missing Test CoverageNo automated tests verify the functions work correctly. Add integration test similar to examples/ffi/libedit-demo.seq 2. Error Handling Documentation GapExamples at docs/FFI_GUIDE.md:243,249 use drop without explaining:
3. Tilde Expansion UnclearExamples use ~/.myapp_history but don't clarify if tilde expansion is handled by the library 4. Missing Stack Effect ValidationAdd test in crates/compiler/src/ffi.rs to verify libedit manifest parses correctly SummaryPR needs SIGNIFICANT REWORK due to critical API incompatibility. Code quality and documentation style are good, but fundamental approach is flawed. Required Changes
Suggested Enhancements
ReferencesWould you like help implementing the native libedit API or switching to GNU readline? |
for #82 example proves for the reviewer that this PR is using the correct APIs for history and there is no accidental pollution of our code with readline gpl3 dependencies. ⏺ Documentation now clarifies: 1. FFI functions pass paths as-is - this is standard C library behavior 2. Path resolution is the application's responsibility - not the FFI's job 3. Future std:os module could provide getenv for building paths like $HOME/.myapp_history This frames it correctly - it's not a limitation, it's proper separation of concerns. The FFI provides the C functions; your app handles its own environment.
PR Review: Add Persistent History Support to ffi:libeditSummaryThis PR adds ✅ Strengths1. Clean FFI Binding Design
2. Excellent Documentation
3. Practical Demo
4. Addresses the Original Issue
🔍 Areas for Consideration1. Error Handling Pattern In both the documentation example and demo, errors are silently ignored: While this is reasonable for Suggestion: Consider documenting error handling patterns more explicitly: 2. File Path Expansion Limitation The documentation correctly notes that shell expansion isn't performed, but this could be a usability issue. Users might expect Considerations:
3. Test Coverage Missing: No automated tests for the new functionality. Suggestions:
4. Memory Safety Considerations The FFI passes strings as args = [
{ type = "string", pass = "c_string" }
]Questions to verify:
The libedit API is well-established and should be safe, but worth documenting FFI safety assumptions. 🔒 Security Concerns1. Path Traversal (Low Risk)
2. File Permissions
Verdict: Security concerns are minimal and appropriate for an FFI binding. The code doesn't introduce vulnerabilities beyond standard file I/O risks. ⚡ Performance Considerations
Note: The demo calls these functions at startup and shutdown, which is the correct pattern. 📊 Code QualityFormatting & Style:
Documentation:
🎯 RecommendationsMust Have (Blockers)None - the PR is functional and well-documented. Should Have (Strongly Recommended)
Nice to Have
✅ VerdictApproved with suggestions. This is a solid, well-documented addition that directly addresses the requested feature. The FFI bindings are correct, the documentation is thorough, and the example demonstrates proper usage. The main gap is test coverage, which should be added before merging. The code quality is high, and the implementation shows good understanding of both the FFI system and the libedit API. The notes about path expansion limitations and the clear separation of concerns between FFI and application-level logic are particularly well done. Recommendation: Merge after adding basic integration tests. Great work on the implementation and documentation! The attention to detail in explaining the path expansion limitation and providing context about future |
⏺ The implementation is complete. Here's what was added:
New functions in ffi:libedit:
Files changed:
Usage example:
include ffi:libedit
: main ( -- Int )
"
/.seqlisp_history" read-history drop # Load on startup/.seqlisp_history" write-history drop # Save on exitrun-repl
"
0
;