Skip to content

Commit 9d8d023

Browse files
authored
[200_61] 更新 README 文档,移除 Scala data pipeline 相关内容 (#662)
1 parent e03553f commit 9d8d023

4 files changed

Lines changed: 88 additions & 192 deletions

File tree

README.md

Lines changed: 15 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,19 @@
33
44
Goldfish Scheme is a Scheme interpreter with the following features:
55
+ R7RS-small compatible
6-
+ Scala-like functional collection
76
+ Python-like versatile standard library
7+
+ AI Coding friendly
88
+ Small and fast
99

1010
<img src="GoldfishScheme-logo.png" alt="示例图片" style="width: 360pt;">
1111

12-
## Demo Code
13-
### Named parameter
14-
``` scheme
15-
(define* (person (name "Bob") (age 21))
16-
(string-append name ": " (number->string age)))
17-
18-
(person :name "Alice" :age 3)
19-
```
20-
### Unicode Support
21-
``` scheme
22-
(import (liii lang))
23-
24-
($ "你好,世界" 0) ; => 你
25-
($ "你好,世界" 4) ; => 界
26-
($ "你好,世界" :length) ; => 5
27-
```
28-
29-
### Functional Data Pipeline
30-
![](r7rs_vs_goldfish.png)
31-
32-
With `prime?` provided, filter twin prime numbers in this way:
33-
``` scheme
34-
(import (liii lang))
35-
36-
(($ 1 :to 100)
37-
:filter prime?
38-
:filter (lambda (x) (prime? (+ x 2)))
39-
:map (lambda (x) (cons x (+ x 2)))
40-
:collect)
41-
```
42-
43-
### Scala like case class
44-
``` scheme
45-
(define-case-class person
46-
((name string?)
47-
(age integer?))
48-
49-
(define (%to-string)
50-
(string-append "I am " name " " (number->string age) " years old!"))
51-
(define (%greet x)
52-
(string-append "Hi " x ", " (%to-string))))
53-
54-
(define bob (person "Bob" 21))
55-
56-
(bob :to-string) ; => "I am Bob 21 years old!"
57-
(bob :greet "Alice") ; => "Hi Alice, I am Bob 21 years old!"
58-
```
59-
60-
> **Performance Warning**: `define-case-class` is implemented via macros and has significant performance overhead. It is suitable for hand-written code and prototyping, but **not recommended for AI-generated code or production deployments**.
61-
6212
## Simplicity is Beauty
6313
Goldfish Scheme still follows the same principle of simplicity as S7 Scheme. Currently, Goldfish Scheme only depends on [S7 Scheme](https://ccrma.stanford.edu/software/s7/), [tbox](https://gitee.com/tboox/tbox) and C++ standard library defined in C++ 98.
6414

6515
Just like S7 Scheme, [src/goldfish.hpp](src/goldfish.hpp) and [src/goldfish.cpp](src/goldfish.cpp) are the only key source code needed to build the goldfish interpreter binary.
6616

6717

6818
## Standard Library
69-
### Scala-like collections
70-
| Library | Description |
71-
|---------|-------------|
72-
| [(liii rich-char)](tests/goldfish/liii/rich-char-test.scm) | boxed char with rich char and instance methods |
73-
| [(liii rich-string)](tests/goldfish/liii/rich-string-test.scm) | boxed string with rich char and instance methods |
74-
| [(liii rich-list)](tests/goldfish/liii/rich-list-test.scm) | boxed list with rich static and instance methods |
75-
| [(liii rich-vector)](tests/goldfish/liii/rich-vector-test.scm) | boxed vector with rich static and instance methods |
76-
| [(liii rich-hash-table)](tests/goldfish/liii/rich-hash-table-test.scm) | boxed hash-table with rich static and instance methods |
77-
| [(liii rich-path)](tests/goldfish/liii/rich-path-test.scm) | boxed path with rich static and instance methods |
78-
7919
### Python-like standard library
8020

8121
| Library | Description | Example functions |
@@ -94,7 +34,10 @@ Just like S7 Scheme, [src/goldfish.hpp](src/goldfish.hpp) and [src/goldfish.cpp]
9434
| [(liii path)](goldfish/liii/path.scm) | Path Library | `path-dir?`, `path-file?` |
9535
| [(liii range)](goldfish/liii/range.scm) | Range Library | `numeric-range`, `iota` |
9636
| [(liii option)](goldfish/liii/option.scm) | Option Type Library | `option?`, `option-map`, `option-flatten` |
37+
| [(liii either)](goldfish/liii/either.scm) | Either Type Library | `left?`, `right?`, `either-map` |
9738
| [(liii uuid)](goldfish/liii/uuid.scm) | UUID generation | `uuid4` |
39+
| [(liii http)](goldfish/liii/http.scm) | HTTP client library | `http-get`, `http-post`, `http-head` |
40+
| [(liii json)](goldfish/liii/json.scm) | JSON parsing and manipulation | `string->json`, `json->string` |
9841

9942

10043
### SRFI
@@ -131,26 +74,6 @@ Besides the Goldfish Scheme interpreter, a nice structured [Goldfish Scheme REPL
13174

13275
The following guide will help you build and install Goldfish step by step.
13376

134-
### GNU/Linux
135-
Here are commandlines to build it on Debian bookworm:
136-
```
137-
sudo apt install xmake git unzip curl g++
138-
git clone https://gitee.com/LiiiLabs/goldfish.git
139-
# git clone https://github.com/LiiiLabs/goldfish.git
140-
cd goldfish
141-
xmake b goldfish
142-
bin/gf --version
143-
```
144-
You can also install it to `/opt`:
145-
```
146-
sudo xmake i -o /opt/goldfish --root
147-
/opt/goldfish/bin/gf
148-
```
149-
For uninstallation, just:
150-
```
151-
sudo rm -rf /opt/goldfish
152-
```
153-
15477
### macOS
15578
Here are commandlines to build it on macOS:
15679
```
@@ -163,7 +86,7 @@ brew uninstall goldfish
16386
```
16487

16588
## Commandlinefu
166-
This section assumes you have executed `xmake b goldfish` sucessfully and `bin/gf` is available.
89+
If you build from source manually, you can find the executable at `bin/gf`.
16790

16891
### Subcommands
16992

@@ -184,7 +107,7 @@ Goldfish Scheme uses subcommands for different operations:
184107
### Display Help
185108
Without any command, it will print the help message:
186109
```
187-
> bin/gf
110+
> gf
188111
Goldfish Scheme 17.11.37 by LiiiLabs
189112
190113
Commands:
@@ -198,41 +121,41 @@ Commands:
198121
### Display Version
199122
`version` subcommand will print the Goldfish Scheme version and the underlying S7 Scheme version:
200123
```
201-
> bin/gf version
124+
> gf version
202125
Goldfish Scheme 17.11.37 by LiiiLabs
203126
based on S7 Scheme 11.5 (22-Sep-2025)
204127
```
205128

206129
### Evaluate Code
207130
`eval` subcommand helps you evaluate Scheme code on the fly:
208131
```
209-
> bin/gf eval "(+ 1 2)"
132+
> gf eval "(+ 1 2)"
210133
3
211-
> bin/gf eval "(begin (import (srfi srfi-1)) (first (list 1 2 3)))"
134+
> gf eval "(begin (import (srfi srfi-1)) (first (list 1 2 3)))"
212135
1
213-
> bin/gf eval "(begin (import (liii sys)) (display (argv)) (newline))" 1 2 3
136+
> gf eval "(begin (import (liii sys)) (display (argv)) (newline))" 1 2 3
214137
("bin/gf" "eval" "(begin (import (liii sys)) (display (argv)) (newline))" "1" "2" "3")
215138
```
216139

217140
### Load File
218141
`load` subcommand helps you load a Scheme file and enter REPL:
219142
```
220-
> bin/gf load tests/goldfish/liii/base-test.scm
143+
> gf load tests/goldfish/liii/base-test.scm
221144
; load the file and enter REPL
222145
```
223146

224147
### Run File Directly
225148
You can also load and evaluate a Scheme file directly:
226149
```
227-
> bin/gf tests/goldfish/liii/base-test.scm
150+
> gf tests/goldfish/liii/base-test.scm
228151
; *** checks *** : 1973 correct, 0 failed.
229152
```
230153

231154
### Mode Option
232155
`-m` or `--mode` helps you specify the standard library mode:
233156

234-
+ `default`: `-m default` is the equiv of `-m liii`
235-
+ `liii`: Goldfish Scheme with `(liii oop)`, `(liii base)` and `(liii error)`
157+
+ `default`: `-m default` is the equiv of `-m r7rs`
158+
+ `liii`: Goldfish Scheme with `(liii base)`, `(liii error)` and `(liii string)`
236159
+ `scheme`: Goldfish Scheme with `(liii base)` and `(liii error)`
237160
+ `sicp`: S7 Scheme with `(scheme base)` and `(srfi sicp)`
238161
+ `r7rs`: S7 Scheme with `(scheme base)`
@@ -246,7 +169,7 @@ Goldfish also supports extra library search directories during startup:
246169

247170
For example:
248171
```bash
249-
bin/gf -I ~/.local/goldfish/liii-goldfix eval "(begin (import (liii goldfix)) 'ok)"
172+
gf -I ~/.local/goldfish/liii-goldfix eval "(begin (import (liii goldfix)) 'ok)"
250173
```
251174

252175
On startup, Goldfish also automatically prepends each directory under `~/.local/goldfish/` whose name matches `xxx-yyy` and which contains at least one `.scm` file.

README_ZH.md

Lines changed: 16 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -3,84 +3,23 @@
33
44
金鱼Scheme 是一个 Scheme 解释器,具有以下特性:
55
+ 兼容 R7RS-small 标准
6-
+ 提供类似 Scala 的函数式集合库
76
+ 提供类似 Python 的功能丰富的标准库
7+
+ AI 编程友好
88
+ 小巧且快速
99

1010
<img src="GoldfishScheme-logo.png" alt="示例图片" style="width: 360pt;">
1111

12-
## 示例代码
13-
### 具名参数
14-
``` scheme
15-
(define* (person (name "Bob") (age 21))
16-
(string-append name ": " (number->string age)))
17-
18-
(person :name "Alice" :age 3)
19-
```
20-
### Unicode支持
21-
``` scheme
22-
(import (liii lang))
23-
24-
($ "你好,世界" 0) ; => 你
25-
($ "你好,世界" 4) ; => 界
26-
($ "你好,世界" :length) ; => 5
27-
```
28-
29-
### 函数式数据管道
30-
![](r7rs_vs_goldfish.png)
31-
32-
`prime?`已提供的情况下,用如下方法过滤出1到100的孪生质数(致敬张益唐):
33-
``` scheme
34-
(import (liii lang))
35-
36-
(($ 1 :to 100)
37-
:filter prime?
38-
:filter (lambda (x) (prime? (+ x 2)))
39-
:map (lambda (x) (cons x (+ x 2)))
40-
:collect)
41-
```
42-
43-
### 类似Scala的case class
44-
``` scheme
45-
(define-case-class person
46-
((name string?)
47-
(age integer?))
48-
49-
(define (%to-string)
50-
(string-append "I am " name " " (number->string age) " years old!"))
51-
(define (%greet x)
52-
(string-append "Hi " x ", " (%to-string))))
53-
54-
(define bob (person "Bob" 21))
55-
56-
(bob :to-string) ; => "I am Bob 21 years old!"
57-
(bob :greet "Alice") ; => "Hi Alice, I am Bob 21 years old!"
58-
```
59-
60-
> **性能警告**`define-case-class` 通过宏实现,有显著的性能开销。它适合手写代码和原型开发,但**不推荐用于 AI 生成的代码或生产环境部署**
61-
6212
## 以简为美
6313
金鱼Scheme仍旧遵循和 S7 Scheme 一样的简约的原则。目前,它仅依赖于 [S7 Scheme](https://ccrma.stanford.edu/software/s7/)[tbox](https://gitee.com/tboox/tbox) 和 C++98 范围内的标准库。
6414

6515
与 S7 Scheme 类似,[src/goldfish.hpp](src/goldfish.hpp)[src/goldfish.cpp](src/goldfish.cpp) 是构建金鱼Scheme解释器二进制文件所需的唯一关键源代码。
6616

6717
## 标准库
68-
### 类似Scala的集合
69-
|| 描述 |
70-
|------------------------------------------------------------|------------------------------------|
71-
| [(liii rich-char)](tests/goldfish/liii/rich-char-test.scm) | 面向`char`的静态方法和实例方法 |
72-
| [(liii rich-string)](tests/goldfish/liii/rich-string-test.scm) | 面向`string`的静态方法和实例方法 |
73-
| [(liii rich-list)](tests/goldfish/liii/rich-list-test.scm) | 面向`list`的静态方法和实例方法 |
74-
| [(liii rich-vector)](tests/goldfish/liii/rich-vector-test.scm) | 面向`vector`的静态方法和实例方法 |
75-
| [(liii rich-hash-table)](tests/goldfish/liii/rich-hash-table-test.scm) | 面向`hash-table`的静态方法和实例方法 |
76-
| [(liii rich-path)](tests/goldfish/liii/rich-path-test.scm) | 面向`path`的静态方法和实例方法 |
77-
7818
### 类似Python的标准库
79-
形如`(liii xyz)`的是金鱼标准库,模仿Python标准库和Scala集合库的函数接口和实现方式,降低用户的学习成本。
19+
形如`(liii xyz)`的是金鱼标准库,模仿Python标准库的函数接口和实现方式,降低用户的学习成本。
8020

8121
|| 描述 | 示例函数 |
8222
| ------------------------------------------------- | ------------------------------- | ------------------------------------------------------------------ |
83-
| [(liii lang)](goldfish/liii/lang.scm) | 类似Scala的集合库 | `box`支持一致的函数式集合库, `rich-char``rich-string`支持Unicode |
8423
| [(liii base)](goldfish/liii/base.scm) | 基础库 | `==`, `!=`, `display*` |
8524
| [(liii error)](goldfish/liii/error.scm) | 提供类似Python的错误函数 | `os-error`函数抛出`'os-error`,类似Python的OSError |
8625
| [(liii check)](goldfish/liii/check.scm) | 基于SRFI 78的轻量级测试库加强版 | `check`, `check-catch` |
@@ -95,7 +34,10 @@
9534
| [(liii path)](goldfish/liii/path.scm) | 路径函数库 | `path-dir?`, `path-file?` |
9635
| [(liii range)](goldfish/liii/range.scm) | 范围库 | `numeric-range`, `iota` |
9736
| [(liii option)](goldfish/liii/option.scm) | Option 类型库 | `option?`, `option-map`, `option-flatten` |
37+
| [(liii either)](goldfish/liii/either.scm) | Either 类型库(左值/右值) | `left?`, `right?`, `either-map` |
9838
| [(liii uuid)](goldfish/liii/uuid.scm) | UUID 生成 | `uuid4` |
39+
| [(liii http)](goldfish/liii/http.scm) | HTTP 客户端库 | `http-get`, `http-post`, `http-head` |
40+
| [(liii json)](goldfish/liii/json.scm) | JSON 解析和操作 | `string->json`, `json->string` |
9941

10042
### SRFI
10143

@@ -132,26 +74,6 @@
13274

13375
以下是分步构建和安装指南。
13476

135-
### GNU/Linux
136-
以下是在 Debian bookworm 上构建的命令:
137-
```
138-
sudo apt install xmake git unzip curl g++
139-
git clone https://gitee.com/LiiiLabs/goldfish.git
140-
# git clone https://github.com/LiiiLabs/goldfish.git
141-
cd goldfish
142-
xmake b goldfish
143-
bin/gf --version
144-
```
145-
您也可以将其安装到 `/opt`
146-
```
147-
sudo xmake i -o /opt/goldfish --root
148-
/opt/goldfish/bin/gf
149-
```
150-
卸载时只需:
151-
```
152-
sudo rm -rf /opt/goldfish
153-
```
154-
15577
### macOS 安装
15678
在 macOS 上,推荐使用 Homebrew 进行安装:
15779
```
@@ -169,7 +91,7 @@ brew uninstall goldfish
16991
```
17092

17193
## 命令行技巧
172-
本节假设您已成功执行 `xmake b goldfish` 并且 `bin/gf` 可用
94+
如果您手动从源码编译,可以在 `bin/gf` 找到可执行文件
17395

17496
### 子命令
17597

@@ -190,7 +112,7 @@ brew uninstall goldfish
190112
### 显示帮助
191113
不带任何命令时,将打印帮助信息:
192114
```
193-
> bin/gf
115+
> gf
194116
Goldfish Scheme 17.11.37 by LiiiLabs
195117
196118
Commands:
@@ -204,41 +126,41 @@ Commands:
204126
### 显示版本
205127
`version` 子命令将打印 金鱼Scheme 版本和底层 S7 Scheme 版本:
206128
```
207-
> bin/gf version
129+
> gf version
208130
Goldfish Scheme 17.11.37 by LiiiLabs
209131
based on S7 Scheme 11.5 (22-Sep-2025)
210132
```
211133

212134
### 求值代码
213135
`eval` 子命令帮助您即时求值 Scheme 代码:
214136
```
215-
> bin/gf eval "(+ 1 2)"
137+
> gf eval "(+ 1 2)"
216138
3
217-
> bin/gf eval "(begin (import (srfi srfi-1)) (first (list 1 2 3)))"
139+
> gf eval "(begin (import (srfi srfi-1)) (first (list 1 2 3)))"
218140
1
219-
> bin/gf eval "(begin (import (liii sys)) (display (argv)) (newline))" 1 2 3
141+
> gf eval "(begin (import (liii sys)) (display (argv)) (newline))" 1 2 3
220142
("bin/gf" "eval" "(begin (import (liii sys)) (display (argv)) (newline))" "1" "2" "3")
221143
```
222144

223145
### 加载文件
224146
`load` 子命令帮助您加载 Scheme 文件并进入 REPL:
225147
```
226-
> bin/gf load tests/goldfish/liii/base-test.scm
148+
> gf load tests/goldfish/liii/base-test.scm
227149
; 加载文件并进入 REPL
228150
```
229151

230152
### 直接运行文件
231153
您也可以直接加载并求值 Scheme 文件:
232154
```
233-
> bin/gf tests/goldfish/liii/base-test.scm
155+
> gf tests/goldfish/liii/base-test.scm
234156
; *** checks *** : 1973 correct, 0 failed.
235157
```
236158

237159
### 模式选项
238160
`-m``--mode` 帮助您指定标准库模式:
239161

240-
+ `default`: `-m default` 等价于 `-m liii`
241-
+ `liii`: 预加载 `(liii oop)``(liii base)``(liii error)` 的 Goldfish Scheme
162+
+ `default`: `-m default` 等价于 `-m r7rs`
163+
+ `liii`: 预加载 `(liii base)``(liii error)``(liii string)` 的 Goldfish Scheme
242164
+ `scheme`: 预加载 `(liii base)``(liii error)` 的 Goldfish Scheme
243165
+ `sicp`: 预加载 `(scheme base)``(srfi sicp)` 的 S7 Scheme
244166
+ `r7rs`: 预加载 `(scheme base)` 的 S7 Scheme
@@ -252,7 +174,7 @@ Goldfish 启动时也支持额外的库搜索目录:
252174

253175
例如:
254176
```bash
255-
bin/gf -I ~/.local/goldfish/liii-goldfix eval "(begin (import (liii goldfix)) 'ok)"
177+
gf -I ~/.local/goldfish/liii-goldfix eval "(begin (import (liii goldfix)) 'ok)"
256178
```
257179

258180
启动时,Goldfish 还会自动把 `~/.local/goldfish/` 下所有名称匹配 `xxx-yyy` 且至少包含一个 `.scm` 文件的目录前置到库搜索路径中。

0 commit comments

Comments
 (0)