-
Notifications
You must be signed in to change notification settings - Fork 35
[200_61] 更新 README 文档,移除 Scala data pipeline 相关内容 #662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
88734d4
5b8060b
6ec3f63
42599e9
214f29d
cd86822
db04114
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,6 @@ | |
|
|
||
| 金鱼Scheme 是一个 Scheme 解释器,具有以下特性: | ||
| + 兼容 R7RS-small 标准 | ||
| + 提供类似 Scala 的函数式集合库 | ||
| + 提供类似 Python 的功能丰富的标准库 | ||
| + 小巧且快速 | ||
|
|
||
|
|
@@ -17,70 +16,18 @@ | |
|
|
||
| (person :name "Alice" :age 3) | ||
| ``` | ||
| ### Unicode支持 | ||
| ``` scheme | ||
| (import (liii lang)) | ||
|
|
||
| ($ "你好,世界" 0) ; => 你 | ||
| ($ "你好,世界" 4) ; => 界 | ||
| ($ "你好,世界" :length) ; => 5 | ||
| ``` | ||
|
|
||
| ### 函数式数据管道 | ||
|  | ||
|
|
||
| 在`prime?`已提供的情况下,用如下方法过滤出1到100的孪生质数(致敬张益唐): | ||
| ``` scheme | ||
| (import (liii lang)) | ||
|
|
||
| (($ 1 :to 100) | ||
| :filter prime? | ||
| :filter (lambda (x) (prime? (+ x 2))) | ||
| :map (lambda (x) (cons x (+ x 2))) | ||
| :collect) | ||
| ``` | ||
|
|
||
| ### 类似Scala的case class | ||
| ``` scheme | ||
| (define-case-class person | ||
| ((name string?) | ||
| (age integer?)) | ||
|
|
||
| (define (%to-string) | ||
| (string-append "I am " name " " (number->string age) " years old!")) | ||
| (define (%greet x) | ||
| (string-append "Hi " x ", " (%to-string)))) | ||
|
|
||
| (define bob (person "Bob" 21)) | ||
|
|
||
| (bob :to-string) ; => "I am Bob 21 years old!" | ||
| (bob :greet "Alice") ; => "Hi Alice, I am Bob 21 years old!" | ||
| ``` | ||
|
|
||
| > **性能警告**:`define-case-class` 通过宏实现,有显著的性能开销。它适合手写代码和原型开发,但**不推荐用于 AI 生成的代码或生产环境部署**。 | ||
|
|
||
| ## 以简为美 | ||
| 金鱼Scheme仍旧遵循和 S7 Scheme 一样的简约的原则。目前,它仅依赖于 [S7 Scheme](https://ccrma.stanford.edu/software/s7/) 、[tbox](https://gitee.com/tboox/tbox) 和 C++98 范围内的标准库。 | ||
|
|
||
| 与 S7 Scheme 类似,[src/goldfish.hpp](src/goldfish.hpp) 和 [src/goldfish.cpp](src/goldfish.cpp) 是构建金鱼Scheme解释器二进制文件所需的唯一关键源代码。 | ||
|
|
||
| ## 标准库 | ||
| ### 类似Scala的集合 | ||
| | 库 | 描述 | | ||
| |------------------------------------------------------------|------------------------------------| | ||
| | [(liii rich-char)](tests/goldfish/liii/rich-char-test.scm) | 面向`char`的静态方法和实例方法 | | ||
| | [(liii rich-string)](tests/goldfish/liii/rich-string-test.scm) | 面向`string`的静态方法和实例方法 | | ||
| | [(liii rich-list)](tests/goldfish/liii/rich-list-test.scm) | 面向`list`的静态方法和实例方法 | | ||
| | [(liii rich-vector)](tests/goldfish/liii/rich-vector-test.scm) | 面向`vector`的静态方法和实例方法 | | ||
| | [(liii rich-hash-table)](tests/goldfish/liii/rich-hash-table-test.scm) | 面向`hash-table`的静态方法和实例方法 | | ||
| | [(liii rich-path)](tests/goldfish/liii/rich-path-test.scm) | 面向`path`的静态方法和实例方法 | | ||
|
|
||
| ### 类似Python的标准库 | ||
| 形如`(liii xyz)`的是金鱼标准库,模仿Python标准库和Scala集合库的函数接口和实现方式,降低用户的学习成本。 | ||
| 形如`(liii xyz)`的是金鱼标准库,模仿Python标准库的函数接口和实现方式,降低用户的学习成本。 | ||
|
|
||
| | 库 | 描述 | 示例函数 | | ||
| | ------------------------------------------------- | ------------------------------- | ------------------------------------------------------------------ | | ||
| | [(liii lang)](goldfish/liii/lang.scm) | 类似Scala的集合库 | `box`支持一致的函数式集合库, `rich-char`和`rich-string`支持Unicode | | ||
| | [(liii base)](goldfish/liii/base.scm) | 基础库 | `==`, `!=`, `display*` | | ||
| | [(liii error)](goldfish/liii/error.scm) | 提供类似Python的错误函数 | `os-error`函数抛出`'os-error`,类似Python的OSError | | ||
| | [(liii check)](goldfish/liii/check.scm) | 基于SRFI 78的轻量级测试库加强版 | `check`, `check-catch` | | ||
|
|
@@ -96,6 +43,8 @@ | |
| | [(liii range)](goldfish/liii/range.scm) | 范围库 | `numeric-range`, `iota` | | ||
| | [(liii option)](goldfish/liii/option.scm) | Option 类型库 | `option?`, `option-map`, `option-flatten` | | ||
| | [(liii uuid)](goldfish/liii/uuid.scm) | UUID 生成 | `uuid4` | | ||
| | [(liii http)](goldfish/liii/http.scm) | HTTP 客户端库 | `http-get`, `http-post`, `http-head` | | ||
| | [(liii json)](goldfish/liii/json.scm) | JSON 解析和操作 | `string->json`, `json->string` | | ||
|
|
||
| ### SRFI | ||
|
|
||
|
|
@@ -132,26 +81,6 @@ | |
|
|
||
| 以下是分步构建和安装指南。 | ||
|
|
||
| ### GNU/Linux | ||
| 以下是在 Debian bookworm 上构建的命令: | ||
| ``` | ||
| sudo apt install xmake git unzip curl g++ | ||
| git clone https://gitee.com/LiiiLabs/goldfish.git | ||
| # git clone https://github.com/LiiiLabs/goldfish.git | ||
| cd goldfish | ||
| xmake b goldfish | ||
| bin/gf --version | ||
| ``` | ||
| 您也可以将其安装到 `/opt`: | ||
| ``` | ||
| sudo xmake i -o /opt/goldfish --root | ||
| /opt/goldfish/bin/gf | ||
| ``` | ||
| 卸载时只需: | ||
| ``` | ||
| sudo rm -rf /opt/goldfish | ||
| ``` | ||
|
|
||
| ### macOS 安装 | ||
| 在 macOS 上,推荐使用 Homebrew 进行安装: | ||
| ``` | ||
|
|
@@ -238,7 +167,7 @@ based on S7 Scheme 11.5 (22-Sep-2025) | |
| `-m` 或 `--mode` 帮助您指定标准库模式: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| + `default`: `-m default` 等价于 `-m liii` | ||
| + `liii`: 预加载 `(liii oop)`、`(liii base)` 和 `(liii error)` 的 Goldfish Scheme | ||
| + `liii`: 预加载 `(liii base)` 和 `(liii error)` 的 Goldfish Scheme | ||
| + `scheme`: 预加载 `(liii base)` 和 `(liii error)` 的 Goldfish Scheme | ||
| + `sicp`: 预加载 `(scheme base)` 和 `(srfi sicp)` 的 S7 Scheme | ||
| + `r7rs`: 预加载 `(scheme base)` 的 S7 Scheme | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # [200_61] 更新 README 文档 | ||
|
|
||
| ## 任务相关的代码文件 | ||
| - README.md | ||
| - README_ZH.md | ||
|
|
||
| ## 2025/04/03 | ||
|
|
||
| ### What | ||
|
|
||
| 1. 移除基于 Scala 的 data pipeline 相关内容 | ||
| - 移除 "Scala-like functional collection" 特性描述 | ||
| - 移除 Functional Data Pipeline 示例代码和图片引用 | ||
| - 移除 Scala like case class 示例和性能警告 | ||
|
|
||
| 2. 移除 (liii lang) 相关内容 | ||
| - 移除 Unicode Support 示例(使用 `(liii lang)`) | ||
| - 从标准库表格中移除 `(liii lang)` 行 | ||
| - 移除 "Scala-like collections" 表格 | ||
|
|
||
| 3. 简化安装说明 | ||
| - 移除 GNU/Linux 安装说明,保留 macOS 安装说明 | ||
|
|
||
| 4. 更新模式选项 | ||
| - 移除 `(liii oop)` 预加载项 | ||
| - `liii` 模式现在只预加载 `(liii base)` 和 `(liii error)` | ||
|
|
||
| 5. 新增标准库 | ||
| - 新增 `(liii http)`:HTTP 客户端库 | ||
| - 新增 `(liii json)`:JSON 解析和操作库 | ||
|
|
||
| ### Why | ||
|
|
||
| 由于基于 Scala 的 data pipeline(包括 `(liii lang)`、case class、rich collections 等)已经从代码库中移除,README 文档需要同步更新,以反映当前 Goldfish Scheme 的实际状态,避免误导用户。 | ||
|
|
||
| 同时,新增 `(liii http)` 和 `(liii json)` 两个实用库的介绍,帮助用户了解 Goldfish Scheme 的网络和 JSON 处理能力。 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4547,9 +4547,16 @@ goldfish_repl (s7_scheme* sc, const string& mode) { | |
| ic_style_def ("symbol", "cyan"); | ||
|
|
||
| ic_printf ("[b gold]Goldfish Scheme[/] [b plum]%s[/] by LiiiLabs\n" | ||
| "[i]Based on S7 Scheme %s [dim](%s)[/][/]\n" | ||
| "[b]Mode:[/] [b]%s[/]\n\n", | ||
| GOLDFISH_VERSION, S7_VERSION, S7_DATE, mode.c_str ()); | ||
| "[i]Based on S7 Scheme %s [dim](%s)[/][/]\n", | ||
| GOLDFISH_VERSION, S7_VERSION, S7_DATE); | ||
| // Display mode info; liii mode shows extra imported libraries | ||
| if (mode == "liii" || mode == "default") { | ||
| ic_printf ("[b]Mode:[/] [b]%s[/] (additionally imports: (liii base) (liii error) (liii string) compared to r7rs)\n\n", | ||
| mode.c_str ()); | ||
| } | ||
| else { | ||
| ic_printf ("[b]Mode:[/] [b]%s[/]\n\n", mode.c_str ()); | ||
| } | ||
| ic_printf ("- Type ',quit' or ',q' to quit. (or use [kbd]ctrl-d[/]).\n" | ||
| "- Type ',help' for REPL commands help.\n" | ||
| "- Press [kbd]F1[/] for help on editing commands.\n" | ||
|
|
@@ -4599,8 +4606,8 @@ struct StartupCliOptions { | |
| }; | ||
|
|
||
| static std::string | ||
| parse_mode_option (int argc, char** argv) { | ||
| std::string mode= "default"; | ||
| parse_mode_option (int argc, char** argv, const std::string& default_mode= "default") { | ||
| std::string mode= default_mode; | ||
| for (int i= 1; i < argc; ++i) { | ||
| string arg= argv[i]; | ||
| if ((arg == "--mode" || arg == "-m") && (i + 1) < argc) { | ||
|
|
@@ -5107,14 +5114,22 @@ repl_for_community_edition (s7_scheme* sc, int argc, char** argv) { | |
|
|
||
| string command = startup_opts.command; | ||
| int command_index= startup_opts.command_index; | ||
| string mode = parse_mode_option (argc, argv); | ||
|
|
||
| // 如果没有找到命令或没有参数,显示帮助 | ||
| if (argc <= 1 || command.empty ()) { | ||
| display_help (); | ||
| return 0; | ||
| } | ||
|
|
||
| // 根据命令类型确定默认模式: | ||
| // - repl/load 命令默认使用 liii 模式 | ||
| // - 其他命令(eval, run, 直接执行脚本)默认使用 r7rs 模式 | ||
| string default_mode= "r7rs"; | ||
| if (command == "repl" || command == "load") { | ||
| default_mode= "liii"; | ||
| } | ||
| string mode= parse_mode_option (argc, argv, default_mode); | ||
|
Comment on lines
+5124
to
+5131
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 此更改将 之前依赖默认模式运行的脚本(如使用 此外,README 中仍描述 如这是有意为之的设计决策,建议:
|
||
|
|
||
| // 处理旧版的 --help, -h, --version, -v(为了向后兼容) | ||
| if (command == "--help" || command == "-h") { | ||
| display_help (); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
liii模式遗漏(liii string)导入README 描述
liii模式仅预加载(liii base)和(liii error),但src/goldfish.hpp中customize_goldfish_by_mode(第 4104–4105 行)的实际代码为:新增的 REPL 欢迎消息(第 4554 行)也已正确反映了这三个库,但 README 的说明遗漏了
(liii string)。建议修正为: