Conversation
Greptile Summary本 PR 将 mogan 内嵌的 Goldfish Scheme 从 v17.11.32 升级到 v17.11.35,主要变化为将大量 Scheme 库文件( 主要变更点:
需关注的问题:
Confidence Score: 4/5存在两处 P1 问题(path-append-text 缺类型检查、path-list-path 返回类型与注释不符),建议修复后合并。 大多数变更是上游库版本同步,逻辑正确;但 path-append-text 遗漏类型守卫是明确的代码退化,path-list-path 注释与行为不一致可能导致调用方误用,因此评分 4/5。 TeXmacs/plugins/goldfish/goldfish/liii/path.scm(两处 P1)和 TeXmacs/plugins/goldfish/src/goldfish.hpp(Windows 兼容性、默认模式导入变更)需要重点关注。 Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[goldfish CLI 启动] --> B[parse_startup_cli_options]
B --> C{解析参数}
C -->|--mode / -m| D[设置 mode]
C -->|-I DIR| E[prepend_dirs]
C -->|-A DIR| F[append_dirs]
C -->|command| G[记录 command & index]
C -->|无效选项| H[display_help & exit]
D & E & F & G --> I[apply_startup_load_path_options]
I --> J[discover_auto_goldfish_library_dirs\n~/.local/goldfish/]
I --> K[prepend_load_path_entries\nappend_load_path_entries]
K --> L[customize_goldfish_by_mode\n默认导入 liii base + liii error + liii string]
L --> M{command 类型}
M -->|test| N[import liii goldtest\n调用 main 函数]
M -->|doc| O[import liii golddoc\n调用 main 函数]
M -->|run / fix / repl| P[原有逻辑]
N & O & P --> Q[返回 exit code]
Reviews (1): Last reviewed commit: "升级到Goldfish Scheme v17.11.35" | Re-trigger Greptile |
| (define (path-append-text p content) | ||
| (g_path-append-text (path->string p) content) | ||
| ) ;define |
There was a problem hiding this comment.
path-write-text(第 540-545 行)在调用 C 层函数之前会验证 content 是否为字符串,而 path-append-text 省略了相同的守卫检查。如果传入非字符串参数,错误将在 C 层(g_path-append-text)内部触发,产生更难调试的错误信息,与 path-write-text 的行为不一致。
| (define (path-append-text p content) | |
| (g_path-append-text (path->string p) content) | |
| ) ;define | |
| (define (path-append-text p content) | |
| (if (not (string? content)) | |
| (type-error "path-append-text: content must be string") | |
| (g_path-append-text (path->string p) content) | |
| ) ;if | |
| ) ;define |
| ;;; List directory contents as path objects | ||
| (define (path-list-path p) | ||
| (let ((base (path->string p))) | ||
| (let ((entries (listdir base))) | ||
| (vector-map | ||
| (lambda (entry) (path-join base entry)) | ||
| entries | ||
| ) ;vector-map | ||
| ) ;let | ||
| ) ;let | ||
| ) ;define |
There was a problem hiding this comment.
函数注释写明 "List directory contents as path objects",但由于新版本的 path-join 始终返回字符串(string-append 的结果),path-list-path 实际返回的是字符串 vector 而非路径对象的 vector。这与旧实现(使用 rich-path 对象的 :/ 操作,返回路径对象)存在行为差异,可能破坏依赖该函数返回可调用路径对象的调用方代码。
如果新 API 设计上就是返回字符串,请更新注释以避免歧义:
| ;;; List directory contents as path objects | |
| (define (path-list-path p) | |
| (let ((base (path->string p))) | |
| (let ((entries (listdir base))) | |
| (vector-map | |
| (lambda (entry) (path-join base entry)) | |
| entries | |
| ) ;vector-map | |
| ) ;let | |
| ) ;let | |
| ) ;define | |
| ;;; List directory contents as path strings | |
| (define (path-list-path p) | |
| (let ((base (path->string p))) | |
| (let ((entries (listdir base))) | |
| (vector-map | |
| (lambda (entry) (path-join base entry)) | |
| entries | |
| ) ;vector-map | |
| ) ;let | |
| ) ;let | |
| ) ;define |
| ) ;define | ||
|
|
||
| (define* (check:proc expression thunk expected-result (equal class=?)) | ||
| (define* (check:proc expression thunk expected-result (equal equal?)) |
There was a problem hiding this comment.
check:proc 默认比较器由 class=? 改为 equal?
旧实现使用 (liii lang) 的 class=? 作为默认比较器,class=? 能够通过 :equals 方法正确比较 case-class 对象。改为 equal? 后,任何调用 (check (some-case-class-expr) => expected) 而不显式传入比较器的测试,将使用 Scheme 原生的 equal?,无法识别 case-class 的 equals 协议,可能导致原本通过的测试出现误判。
如果确认 SRFI-78 在 Goldfish 生态中不再用于 case-class 断言,则此变更可接受;否则建议在 changelog 或注释中明确说明该破坏性变更。
| discover_auto_goldfish_library_dirs () { | ||
| vector<string> dirs; | ||
| const char* home= getenv ("HOME"); | ||
| if ((!home) || (!*home)) { | ||
| return dirs; | ||
| } | ||
|
|
| if (mode == "default" || mode == "liii") { | ||
| s7_eval_c_string (sc, "(import (liii base) (liii error) (liii oop))"); | ||
| s7_eval_c_string (sc, "(import (liii base) (liii error) (liii string))"); | ||
| } |
No description provided.