Skip to content

Commit

Permalink
!119 bump to Goldfish Scheme v17.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii committed Jan 12, 2025
1 parent 802ac0c commit d50ac22
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 9 deletions.
4 changes: 2 additions & 2 deletions GoldfishStandardLibrary.tmu
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<assign|srfi|<flag|SRFI|dark red>>

<assign|goldfish-version|17.11.1>
<assign|goldfish-version|17.11.2>

<assign|typehint|<macro|body|<goldfish-lang|<arg|body>>>>

Expand Down Expand Up @@ -132,7 +132,7 @@
金鱼Scheme的版本,<todo|后续统一使用<value|goldfish-version>这个在导言区预定义的值>。文学编程的Build Buffer功能暂时不支持展开导言区预定义的值。

<\cpp-chunk|src/goldfish.hpp|true|true>
#define GOLDFISH_VERSION "17.11.1"
#define GOLDFISH_VERSION "17.11.2"

\;
</cpp-chunk>
Expand Down
54 changes: 51 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,69 @@
Goldfish Scheme is a Scheme interpreter with the following features:
+ R7RS-small compatible
+ Python-like standard library
+ Scala-like functional collection
+ Python-like versatile standard library
+ Small and fast

<img src="goldfish_scheme_logo.png" alt="示例图片" style="width: 360pt;">

## Demo Code
### Named parameter
``` scheme
(define* (person (name "Bob") (age 21))
(string-append name ": " (number->string age)))
(person :name "Alice" :age 3)
```
### Unicode Support
``` scheme
((box "你好,世界") 0) ; => 你
((box "你好,世界") 4) ; => 界
((box "你好,世界") :length) ; => 5
```

### Functional Data Pipeline
```
((box (list 1 2 3 4 5))
:map (lambda (x) (* x x))
:filter even?
:collect) ; => (list 4 16)
((box (vector 1 2 3 4 5))
:map (lambda (x) (* x x))
:filter even?
:collect) ; => (vector 4 16)
```

### Scala like case class
```
(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!"
```

## Simplicity is Beauty
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.

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.


## Standard Library
### Python-like standard library
### Python-like standard library and Scala-like collections

| Library | Description | Example functions |
|---|---|---|
| [(liii lang)](goldfish/liii/lang.scm) | Scala-like Collection | `box` for functional api, `case-char`, `case-string` for unicode |
| [(liii base)](goldfish/liii/base.scm) | Basic routines | `==`, `!=`, `display*` |
| [(liii error)](goldfish/liii/error.scm) | Python like Errors | `os-error` to raise `'os-error` just like OSError in Python |
| [(liii check)](goldfish/liii/check.scm) | Test framework based on SRFI-78 | `check`, `check-catch` |
Expand Down Expand Up @@ -114,7 +161,8 @@ based on S7 Scheme 10.11 (2-July-2024)
`-m` helps you specify the standard libray mode.

+ `default`: `-m default` is the equiv of `-m liii`
+ `liii`: Goldfish Scheme with `(liii base)` and `(liii error)`
+ `liii`: Goldfish Scheme with `(liii lang)`, `(liii base)` and `(liii error)`
+ `scheme`: Goldfish Scheme with `(liii base)` and `(liii error)`
+ `sicp`: S7 Scheme with `(scheme base)` and `(srfi sicp)`
+ `r7rs`: S7 Scheme with `(scheme base)`
+ `s7`: S7 Scheme without any extra library
Expand Down
54 changes: 51 additions & 3 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,69 @@
金鱼Scheme 是一个 Scheme 解释器,具有以下特性:
+ 兼容 R7RS-small 标准
+ 提供类似 Python 的标准库
+ 提供类似 Scala 的函数式集合库
+ 提供类似 Python 的功能丰富的标准库
+ 小巧且快速

<img src="goldfish_scheme_logo.png" alt="示例图片" style="width: 360pt;">

## 示例代码
### 具名参数
``` scheme
(define* (person (name "Bob") (age 21))
(string-append name ": " (number->string age)))
(person :name "Alice" :age 3)
```
### Unicode支持
``` scheme
((box "你好,世界") 0) ; => 你
((box "你好,世界") 4) ; => 界
((box "你好,世界") :length) ; => 5
```

### 函数式数据管道
```
((box (list 1 2 3 4 5))
:map (lambda (x) (* x x))
:filter even?
:collect) ; => (list 4 16)
((box (vector 1 2 3 4 5))
:map (lambda (x) (* x x))
:filter even?
:collect) ; => (vector 4 16)
```

### 类似Scala的case class
```
(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!"
```

## 以简为美
金鱼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解释器二进制文件所需的唯一关键源代码。

## 标准库
### 金鱼标准库
形如`(liii xyz)`的是金鱼标准库,模仿Python标准库的函数接口和实现方式,降低用户的学习成本。
形如`(liii xyz)`的是金鱼标准库,模仿Python标准库和Scala集合库的函数接口和实现方式,降低用户的学习成本。

|| 描述 | 示例函数 |
| --- | --- | --- |
| [(liii lang)](goldfish/liii/lang.scm) | 类似Scala的集合库 | `box`支持一致的函数式集合库, `case-char``case-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` |
Expand Down Expand Up @@ -118,7 +165,8 @@ based on S7 Scheme 10.11 (2-July-2024)
`-m`帮助您指定预加载的标准库。

+ `default`: `-m default`等价于`-m liii`
+ `liii`: 预加载`(liii base)``(liii error)`的金鱼Scheme
+ `liii`: 预加载`(liii lang)`, `(liii base)``(liii error)`的Goldfish Scheme
+ `scheme`: 预加载`(liii base)``(liii error)`的Goldfish Scheme
+ `sicp`: 预加载`(srfi sicp)``(scheme base)`的S7 Scheme
+ `r7rs`: 预加载`(scheme base)`的S7 Scheme
+ `s7`: 无任何无加载库的S7 Scheme
Expand Down
2 changes: 1 addition & 1 deletion src/goldfish.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include <wordexp.h>
#endif

#define GOLDFISH_VERSION "17.11.1"
#define GOLDFISH_VERSION "17.11.2"

#define GOLDFISH_PATH_MAXN TB_PATH_MAXN

Expand Down

0 comments on commit d50ac22

Please sign in to comment.