Conversation
Implementation Summary
Challenge: The original kv-map ( k1 v1 ... kN vN n -- Map ) design can't work with Seq's type system - it can't express consuming a variable number of stack items based on a runtime value.
Solution: Builder pattern with two simple words:
include std:map
# Build a map with chained operations
map-of "name" "Alice" kv "age" 30 kv
# Multi-line style
map-of
"host" "localhost" kv
"port" 8080 kv
"debug" true kv
Files created/modified:
- crates/compiler/stdlib/map.seq - new stdlib module with map-of and kv
- crates/compiler/src/stdlib_embed.rs - registered the map module
- tests/integration/src/test-kv-map.seq - 6 passing tests
CI status: All 233 compiler tests + 291 runtime tests + 6 new tests pass.
PR Review: Map Builder Pattern ImplementationOverall AssessmentStatus: APPROVED ✅ This PR successfully implements a clean builder pattern for map construction that elegantly solves the type system limitations described in issue #151. The implementation is well-designed, thoroughly tested, and follows existing stdlib conventions. Code Quality & Best PracticesStrengths ✅
Test CoverageStrengths ✅The test suite in
Coverage Analysis:
Potential Issues & SuggestionsMinor Documentation Enhancement 💡Current code (crates/compiler/stdlib/map.seq:22-24): Suggestion: Consider adding a comment about the builder pattern's type safety advantage: This helps explain why this approach was chosen over the alternatives in issue #151. Test Case: Consider Boolean Keys 💡The existing tests cover string and integer keys. For completeness, you might add a test with boolean keys (similar to Performance ConsiderationsNo concerns. The implementation:
Security ConcernsNo concerns. The code:
Bugs or IssuesNone identified. The implementation is correct and handles edge cases properly:
Final RecommendationAPPROVE - This PR is ready to merge. The implementation is:
The builder pattern is a smart solution that works within Seq's type system constraints while providing the ergonomic map construction syntax needed for SON. CI Status: All 233 compiler tests + 291 runtime tests + 6 new tests passing ✅ |
Implementation Summary
#151
Challenge: The original kv-map ( k1 v1 ... kN vN n -- Map ) design can't work with Seq's type system - it can't express consuming a variable number of stack items based on a runtime value.
Solution: Builder pattern with two simple words:
include std:map
Build a map with chained operations
map-of "name" "Alice" kv "age" 30 kv
Multi-line style
map-of
"host" "localhost" kv
"port" 8080 kv
"debug" true kv
Files created/modified:
CI status: All 233 compiler tests + 291 runtime tests + 6 new tests pass.