mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-02 13:41:10 +00:00
Update to zh_TW doc to put translation badges
This commit is contained in:
parent
11b2e31327
commit
53776fc22a
186 changed files with 374 additions and 12 deletions
|
@ -1,5 +1,7 @@
|
||||||
# 內置常量
|
# 內置常量
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/consts.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
## True
|
## True
|
||||||
|
|
||||||
## False
|
## False
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 功能
|
# 功能
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/funcs.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
## 基本功能
|
## 基本功能
|
||||||
|
|
||||||
### if|T; U|(cond: Bool, then: T, else: U) -> T or U
|
### if|T; U|(cond: Bool, then: T, else: U) -> T or U
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/index.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
2
doc/zh_TW/API/modules/external/alstruct.md
vendored
2
doc/zh_TW/API/modules/external/alstruct.md
vendored
|
@ -1,5 +1,7 @@
|
||||||
# 結構
|
# 結構
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/modules/external/alstruct.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
模塊為它們提供代表代數結構和補丁的特征
|
模塊為它們提供代表代數結構和補丁的特征
|
||||||
|
|
||||||
* 成員
|
* 成員
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 模塊`repl`
|
# 模塊`repl`
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/modules/repl.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
提供REPL(Read-Eval-Print-Loop)相關的API。
|
提供REPL(Read-Eval-Print-Loop)相關的API。
|
||||||
|
|
||||||
## 功能
|
## 功能
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 模塊`status`
|
# 模塊`status`
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/modules/status.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
定義了一個類型來表示狀態。請根據情況刪除選項來使用它
|
定義了一個類型來表示狀態。請根據情況刪除選項來使用它
|
||||||
|
|
||||||
* ExecResult = {"success", "warning", "failure", "fatal", "unknown"}
|
* ExecResult = {"success", "warning", "failure", "fatal", "unknown"}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 模塊`unit`
|
# 模塊`unit`
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/modules/unit.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
`unit` 模塊是將數值計算中經常使用的單位定義為類型的模塊。
|
`unit` 模塊是將數值計算中經常使用的單位定義為類型的模塊。
|
||||||
Erg 數值類型包括 `Nat`、`Int`、`Ratio` 等。但是,這些類型沒有關于“數字的含義”的信息,因此可以執行諸如添加米和碼之類的無意義計算。
|
Erg 數值類型包括 `Nat`、`Int`、`Ratio` 等。但是,這些類型沒有關于“數字的含義”的信息,因此可以執行諸如添加米和碼之類的無意義計算。
|
||||||
通過使用 `unit` 模塊,您可以避免錯誤,例如將不同單位的數字傳遞給函數。
|
通過使用 `unit` 模塊,您可以避免錯誤,例如將不同單位的數字傳遞給函數。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 模塊 `unsound`
|
# 模塊 `unsound`
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/modules/unsound.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
讓 API 執行在 Erg 的類型系統中無法保證的不健全和不安全的操作。
|
讓 API 執行在 Erg 的類型系統中無法保證的不健全和不安全的操作。
|
||||||
|
|
||||||
## `unsafe!`
|
## `unsafe!`
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 操作員
|
# 操作員
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/operators.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
## 中綴運算符
|
## 中綴運算符
|
||||||
|
|
||||||
### `_+_`|R; O; A <: Add(R, O)|(x: A, y: R) -> O
|
### `_+_`|R; O; A <: Add(R, O)|(x: A, y: R) -> O
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 過程
|
# 過程
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/procs.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
## print!
|
## print!
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 特殊形式
|
# 特殊形式
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/special.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
特殊形式是不能在 Erg 類型系統中表達的運算符、子程序(等等)。它被`包圍,但實際上無法捕獲。
|
特殊形式是不能在 Erg 類型系統中表達的運算符、子程序(等等)。它被`包圍,但實際上無法捕獲。
|
||||||
此外,為方便起見,還出現了“Pattern”、“Body”和“Conv”等類型,但不存在此類類型。它的含義也取決于上下文。
|
此外,為方便起見,還出現了“Pattern”、“Body”和“Conv”等類型,但不存在此類類型。它的含義也取決于上下文。
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 內置 Erg 類型列表
|
# 內置 Erg 類型列表
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
類型本身的屬性不存儲在 `.__dict__` 中,不能從實例中引用
|
類型本身的屬性不存儲在 `.__dict__` 中,不能從實例中引用
|
||||||
|
|
||||||
## 基本類型
|
## 基本類型
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
# Array! T
|
# Array! T
|
||||||
|
|
||||||
|
[.md%26commit_hash%3Dd15cbbf7b33df0f78a575cff9679d84c36ea3ab1)](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Array!(T).md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示可變長度數組的類型。在編譯時長度未知時使用。 有一個語法糖叫做` [t]!`。在`Array! T = ArrayWithMutLength! T, !_`中被定義
|
表示可變長度數組的類型。在編譯時長度未知時使用。 有一個語法糖叫做` [t]!`。在`Array! T = ArrayWithMutLength! T, !_`中被定義
|
|
@ -1,3 +1,5 @@
|
||||||
# Array T: Type
|
# Array T: Type
|
||||||
|
|
||||||
|
[.md%26commit_hash%3Dd15cbbf7b33df0f78a575cff9679d84c36ea3ab1)](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Array(T).md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
由`Array T = ArrayWithLen T, _`定義。 有一種語法糖叫做`[T]`。
|
由`Array T = ArrayWithLen T, _`定義。 有一種語法糖叫做`[T]`。
|
|
@ -1,5 +1,7 @@
|
||||||
# ArrayWithLen T: Type, N: Nat
|
# ArrayWithLen T: Type, N: Nat
|
||||||
|
|
||||||
|
[.md%26commit_hash%3D06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/ArrayWithLen(T,N).md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
`[T; N]`是語法糖。還有一個[`Array` 類型](./Array.md)省略了長度。
|
`[T; N]`是語法糖。還有一個[`Array` 類型](./Array.md)省略了長度。
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# ArrayWithMutLength! T: Type, N: Nat!
|
# ArrayWithMutLength! T: Type, N: Nat!
|
||||||
|
|
||||||
|
[.md%26commit_hash%3D06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/ArrayWithMutLength!(T,N).md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
一個可變長度數組,其長度在編譯時已知。還有語法糖`ArrayWithMutLength(T, !N) == [T; !N]`
|
一個可變長度數組,其長度在編譯時已知。還有語法糖`ArrayWithMutLength(T, !N) == [T; !N]`
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Class.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Complex
|
# Complex
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Complex.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示復數的類型。在 Erg 中表示數字的類型,例如 Float、Int和Nat,通常派生于Complex
|
表示復數的類型。在 Erg 中表示數字的類型,例如 Float、Int和Nat,通常派生于Complex
|
||||||
|
|
||||||
## 父類
|
## 父類
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Dict! K, V
|
# Dict! K, V
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Dict!.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示字典(哈希Map)的類型。 有一個語法糖叫做`{K: V}`
|
表示字典(哈希Map)的類型。 有一個語法糖叫做`{K: V}`
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Either L, R = L or R
|
# Either L, R = L or R
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Either.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示L或R的類型。 您可以將其視為Or類型的二元形式
|
表示L或R的類型。 您可以將其視為Or類型的二元形式
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Float size
|
# Float size
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Float.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示實數(包含小數的數)的類型。符合IEEE 754的浮點數,在其他語言中一般是float的類型。
|
表示實數(包含小數的數)的類型。符合IEEE 754的浮點數,在其他語言中一般是float的類型。
|
||||||
Float的大小為8(1byte)~128(16byte)。如果只是Float,則表示`Float64`。
|
Float的大小為8(1byte)~128(16byte)。如果只是Float,則表示`Float64`。
|
||||||
Erg 中的 0.1 實際上屬于 Ratio 類型,而不是 Float 類型。沒有浮點類型字面量,它是由 `(Ratio object)f64` 生成的(例如 (1/2)f64, 15f64)。 f64 對應實數 1
|
Erg 中的 0.1 實際上屬于 Ratio 類型,而不是 Float 類型。沒有浮點類型字面量,它是由 `(Ratio object)f64` 生成的(例如 (1/2)f64, 15f64)。 f64 對應實數 1
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Function N: Nat
|
# Function N: Nat
|
||||||
|
|
||||||
|
[.md%26commit_hash%3D06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Function(N).md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
## Function 1 的方法
|
## Function 1 的方法
|
||||||
|
|
||||||
* then(self, g: Self) -> Self
|
* then(self, g: Self) -> Self
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Inf
|
# Inf
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Inf.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
Inf是一個類,其唯一實例是inf。
|
Inf是一個類,其唯一實例是inf。
|
||||||
inf的主要用途是用于區間類型。
|
inf的主要用途是用于區間類型。
|
||||||
例如,大于等于 2 的整數類型是 `2..<inf`,小于等于 0 的實數是 `-inf<..0.0`。
|
例如,大于等于 2 的整數類型是 `2..<inf`,小于等于 0 的實數是 `-inf<..0.0`。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Int
|
# Int
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Int.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示整數的類。 實例為 0、1、-1、300000 等。
|
表示整數的類。 實例為 0、1、-1、300000 等。
|
||||||
很多語言即使在表示自然數的時候也使用Int(類型等價于),但是Erg使用了使用更小的類型的原則,
|
很多語言即使在表示自然數的時候也使用Int(類型等價于),但是Erg使用了使用更小的類型的原則,
|
||||||
建議使用 Nat、NZInt、Interval 類型等。
|
建議使用 Nat、NZInt、Interval 類型等。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# IntRange L, R
|
# IntRange L, R
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/IntRange.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
`L..R`のクラス。
|
`L..R`のクラス。
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Interval begin, end := WellOrder
|
# Interval begin, end := WellOrder
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Interval.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
表示有序集合類型 (WellOrder) 的子類型的類型。Interval 類型具有派生類型,例如 PreOpen(x<..y)。
|
表示有序集合類型 (WellOrder) 的子類型的類型。Interval 類型具有派生類型,例如 PreOpen(x<..y)。
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Iterator.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Kind N: Nat
|
# Kind N: Nat
|
||||||
|
|
||||||
|
[.md%26commit_hash%3D51de3c9d5a9074241f55c043b9951b384836b258)](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Kind(N).md&commit_hash=51de3c9d5a9074241f55c043b9951b384836b258)
|
||||||
|
|
||||||
```python
|
```python
|
||||||
Kind N: Nat = (Type; N) -> Type
|
Kind N: Nat = (Type; N) -> Type
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Matrix T: Num, Shape: [M, N]
|
# Matrix T: Num, Shape: [M, N]
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Matrix.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示矩陣的類型。 它繼承自 Tensor[M, N]
|
表示矩陣的類型。 它繼承自 Tensor[M, N]
|
||||||
|
|
||||||
## 定義
|
## 定義
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
# Module
|
# Module
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Module.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Nat
|
# Nat
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Nat.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
表示自然數的類型。 用于數組索引和范圍類型
|
表示自然數的類型。 用于數組索引和范圍類型
|
||||||
|
|
||||||
## 定義
|
## 定義
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Neg
|
# Neg
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Neg.md&commit_hash=290c43b09f7c3036112a164bed5fd07a1f6a5cda)
|
||||||
|
|
||||||
表示負整數的類型。 Pos和Neg和{0} == Int
|
表示負整數的類型。 Pos和Neg和{0} == Int
|
||||||
它還具有一些值得注意的屬性,例如不被零除和 Neg * Neg == Pos
|
它還具有一些值得注意的屬性,例如不被零除和 Neg * Neg == Pos
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Never
|
# Never
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Never.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
它是所有類型的子類型。 它是一個`Class`,因為它擁有所有的方法,當然還有 `.new`。但是,它沒有實例,并且Erg會在即將創建的那一刻停止。
|
它是所有類型的子類型。 它是一個`Class`,因為它擁有所有的方法,當然還有 `.new`。但是,它沒有實例,并且Erg會在即將創建的那一刻停止。
|
||||||
還有一種叫做`Panic`的類型沒有實例,但是`Never`用于正常終止或故意無限循環,`Panic`用于異常終止。
|
還有一種叫做`Panic`的類型沒有實例,但是`Never`用于正常終止或故意無限循環,`Panic`用于異常終止。
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# NonZero N
|
# NonZero N
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/NonZero.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示非零數的類。 保證除零的安全性
|
表示非零數的類。 保證除零的安全性
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Object
|
# Object
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Object.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
它是所有類型的超類型
|
它是所有類型的超類型
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Operator [...T], O
|
# Operator [...T], O
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Operator.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
是運算符的類型
|
是運算符的類型
|
||||||
|
|
||||||
## 定義
|
## 定義
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Option T = T or NoneType
|
# Option T = T or NoneType
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Option.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
表示“可能失敗”的類型。
|
表示“可能失敗”的類型。
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Pos
|
# Pos
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Pos.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
Pos是一種表示正數(大于或等于1的整數)的類型。
|
Pos是一種表示正數(大于或等于1的整數)的類型。
|
||||||
由于不包括0,因此具有消除被零除的可能性等優點。
|
由于不包括0,因此具有消除被零除的可能性等優點。
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Ratio
|
# Ratio
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Ratio.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示有理數的類型。 它主要用于當您要使用分數時。
|
表示有理數的類型。 它主要用于當您要使用分數時。
|
||||||
實際上,Erg中的/運算符返回 Ratio。1/3等不被評估為 0.33333... 并且被處理為1/3。 此外,0.1 相當于 1/10。 所以`0.1 + 0.2 == 0.3`。 這聽起來很明顯,但在 Python中它是False。
|
實際上,Erg中的/運算符返回 Ratio。1/3等不被評估為 0.33333... 并且被處理為1/3。 此外,0.1 相當于 1/10。 所以`0.1 + 0.2 == 0.3`。 這聽起來很明顯,但在 Python中它是False。
|
||||||
但是,Ratio類型的效率往往比Float類型略低。 在執行速度很重要且不需要精確數值的地方應該使用浮點類型。 然而,正如Rob Pike所說,過早優化是萬惡之源。 在丟棄Ratio類型并使用Float類型之前,請進行真實的性能測試。 業余愛好者無條件偏愛較輕的模具。
|
但是,Ratio類型的效率往往比Float類型略低。 在執行速度很重要且不需要精確數值的地方應該使用浮點類型。 然而,正如Rob Pike所說,過早優化是萬惡之源。 在丟棄Ratio類型并使用Float類型之前,請進行真實的性能測試。 業余愛好者無條件偏愛較輕的模具。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Record
|
# Record
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Record.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
記錄所屬的類。例如,`{i = 1}` 是`Structural {i = Int}` 類型的元素,并且是`{i = Int}` 類的實例
|
記錄所屬的類。例如,`{i = 1}` 是`Structural {i = Int}` 類型的元素,并且是`{i = Int}` 類的實例
|
||||||
請注意,其他類的實例是記錄類型的元素,而不是記錄類的實例
|
請注意,其他類的實例是記錄類型的元素,而不是記錄類的實例
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Result T, E
|
# Result T, E
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Result.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
```python
|
```python
|
||||||
Result T, E <: Error = Either T, E
|
Result T, E <: Error = Either T, E
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
# StrWithLen! N: Nat! = Inherit StrWithLen N
|
# StrWithLen! N: Nat! = Inherit StrWithLen N
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Str!.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示可變長度字符串的類型
|
表示可變長度字符串的類型
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Str
|
# Str
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Str.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
(不變長度)表示字符串的類型。 簡單的 `Str` 類型是刪除了字符數的 `StrWithLen N` 類型(`Str = StrWithLen _`)
|
(不變長度)表示字符串的類型。 簡單的 `Str` 類型是刪除了字符數的 `StrWithLen N` 類型(`Str = StrWithLen _`)
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/StrWithLen.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Subroutine
|
# Subroutine
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Subroutine.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
Func和Proc的基本類型。
|
Func和Proc的基本類型。
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Tensor Shape: [Nat; N]
|
# Tensor Shape: [Nat; N]
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Tensor.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
用于有效操作多維數組的類。 它還定義了諸如多維數組上的乘法之類的操作
|
用于有效操作多維數組的類。 它還定義了諸如多維數組上的乘法之類的操作
|
||||||
Matrix、Vector 等都繼承自該類型
|
Matrix、Vector 等都繼承自該類型
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# TransCell! T: Type!
|
# TransCell! T: Type!
|
||||||
|
|
||||||
|
[.md%26commit_hash%3D06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/TransCell(T).md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
它是一個單元格,其內容可以針對每個模具進行更改。 由于它是T類型的子類型,因此它也表現為T類型
|
它是一個單元格,其內容可以針對每個模具進行更改。 由于它是T類型的子類型,因此它也表現為T類型
|
||||||
當它在初始化時輸入T時很有用,并且在某個點之后總是輸入U
|
當它在初始化時輸入T時很有用,并且在某個點之后總是輸入U
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Tuple T: ...Type
|
# Tuple T: ...Type
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Tuple.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
包含多種類型對象的集合
|
包含多種類型對象的集合
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Type.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
# Vector T: Num, N: Nat
|
# Vector T: Num, N: Nat
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/classes/Vector.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
表示向量的類型。與同名的Rust和C++類型不同,這種類型只處理數字。
|
表示向量的類型。與同名的Rust和C++類型不同,這種類型只處理數字。
|
|
@ -1,5 +1,7 @@
|
||||||
# BinOp L, R, O
|
# BinOp L, R, O
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/patches/BinOp.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
二元運算符的類型
|
二元運算符的類型
|
||||||
|
|
||||||
## 修補程序
|
## 修補程序
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# UnaryOp T, O
|
# UnaryOp T, O
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/patches/UnaryOp.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
一元運算符的類型
|
一元運算符的類型
|
||||||
|
|
||||||
## 定義
|
## 定義
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Add R
|
# Add R
|
||||||
|
|
||||||
|
[.md%26commit_hash%3D06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Add(R,O).md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
```python
|
```python
|
||||||
Add R = Trait {
|
Add R = Trait {
|
||||||
.AddO = Type
|
.AddO = Type
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Div R, O
|
# Div R, O
|
||||||
|
|
||||||
|
[.md%26commit_hash%3D06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Div(R,O).md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
如果除以零沒有錯誤,請使用“SafeDiv”
|
如果除以零沒有錯誤,請使用“SafeDiv”
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Eq.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Into T
|
# Into T
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Into.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
一種類型,表明它可以被類型轉換為類型T。
|
一種類型,表明它可以被類型轉換為類型T。
|
||||||
即使Self和T之間沒有繼承關系,也是在關系可以相互轉換的時候定義的。
|
即使Self和T之間沒有繼承關系,也是在關系可以相互轉換的時候定義的。
|
||||||
與繼承不同,沒有隱式轉換。您必須始終調用 `.into` 方法。
|
與繼承不同,沒有隱式轉換。您必須始終調用 `.into` 方法。
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Iterable.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Num
|
# Num
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Num.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
## 定義初始化
|
## 定義初始化
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Ord.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# SafeDiv R, O
|
# SafeDiv R, O
|
||||||
|
|
||||||
|
[.md%26commit_hash%3D06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/SafeDiv(R,O).md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
```python
|
```python
|
||||||
SafeDiv R, O = Subsume Div, {
|
SafeDiv R, O = Subsume Div, {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Sample
|
# Sample
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Sample.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
具有“隨機”選擇實例的`sample`和`sample!`方法的特征。`sample`方法總是返回相同的實例,而`sample!`方法返回一個隨機實例,該實例隨調用而變化
|
具有“隨機”選擇實例的`sample`和`sample!`方法的特征。`sample`方法總是返回相同的實例,而`sample!`方法返回一個隨機實例,該實例隨調用而變化
|
||||||
|
|
||||||
請注意,這是一個假設您想要一個適當的實例進行測試等的特征,并且它不一定是隨機的。 如果您想要隨機抽樣,請使用“隨機”模塊。
|
請注意,這是一個假設您想要一個適當的實例進行測試等的特征,并且它不一定是隨機的。 如果您想要隨機抽樣,請使用“隨機”模塊。
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Seq.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Show.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Unpack
|
# Unpack
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/API/types/traits/Unpack.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
標記性狀。實現時,元素可以像記錄一樣通過模式匹配來分解
|
標記性狀。實現時,元素可以像記錄一樣通過模式匹配來分解
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
# 提示(未實現)
|
# 提示(未實現)
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/TODO_hint.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
* `x 未定義`(x 已被`Del` 刪除)=> `提示:在第 X 行刪除`
|
* `x 未定義`(x 已被`Del` 刪除)=> `提示:在第 X 行刪除`
|
||||||
*補丁方法重復:“提示:指定補丁(如`T.foo(1)`)或使用`Del`刪除任何`.foo`”
|
*補丁方法重復:“提示:指定補丁(如`T.foo(1)`)或使用`Del`刪除任何`.foo`”
|
|
@ -1,5 +1,7 @@
|
||||||
# 錯誤恢復建議(尚未實現)
|
# 錯誤恢復建議(尚未實現)
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/TODO_recov_suggest.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
* `1 or 2`, `1 and 2` => `{1, 2}`?
|
* `1 or 2`, `1 and 2` => `{1, 2}`?
|
||||||
* `U = Inherit T` => 非類類型不能被繼承,或者`U = Class T`?
|
* `U = Inherit T` => 非類類型不能被繼承,或者`U = Class T`?
|
||||||
* `Int and Str` => 不允許多重繼承,或者`Int or Str`?
|
* `Int and Str` => 不允許多重繼承,或者`Int or Str`?
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 警告(尚未實現)
|
# 警告(尚未實現)
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/TODO_warn.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
* `t = {(record type)}` => `T = {(record type)}`?(只有定義為常量的類型才能用于類型說明)
|
* `t = {(record type)}` => `T = {(record type)}`?(只有定義為常量的類型才能用于類型說明)
|
||||||
* `{I: Int | ...}!` => `{I: Int! | ...}`
|
* `{I: Int | ...}!` => `{I: Int! | ...}`
|
||||||
* for/while 塊中的`return x`(`x != ()`) => `f::return`(外部塊)?
|
* for/while 塊中的`return x`(`x != ()`) => `f::return`(外部塊)?
|
|
@ -1,5 +1,7 @@
|
||||||
# 廢棄/拒絕的語言規范
|
# 廢棄/拒絕的語言規范
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/abandoned.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
## 重載(臨時多態性)
|
## 重載(臨時多態性)
|
||||||
|
|
||||||
被放棄了,因為它可以用參數+子類型多態來代替,并且與Python的語義不兼容。 有關詳細信息,請參閱 [overload](../syntax/type/overloading.md) 文章。
|
被放棄了,因為它可以用參數+子類型多態來代替,并且與Python的語義不兼容。 有關詳細信息,請參閱 [overload](../syntax/type/overloading.md) 文章。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# `ergc` 的架構
|
# `ergc` 的架構
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/architecture.md&commit_hash=a711efa99b325ba1012f6897e7b0e2bdb947d8a1)
|
||||||
|
|
||||||
## 1. 掃描 Erg 腳本 (.er) 并生成 `TokenStream` (parser/lex.rs)
|
## 1. 掃描 Erg 腳本 (.er) 并生成 `TokenStream` (parser/lex.rs)
|
||||||
|
|
||||||
* parser/lexer/Lexer 生成`TokenStream`(這是一個Token的迭代器,TokenStream可以通過lexer.collect()生成)
|
* parser/lexer/Lexer 生成`TokenStream`(這是一個Token的迭代器,TokenStream可以通過lexer.collect()生成)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Erg Compiler Errors
|
# Erg Compiler Errors
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/errors.md&commit_hash=51de3c9d5a9074241f55c043b9951b384836b258)
|
||||||
|
|
||||||
## AssignError
|
## AssignError
|
||||||
|
|
||||||
嘗試重寫不可變變量時發生
|
嘗試重寫不可變變量時發生
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 高級中間表示(HIR, High-level Intermediate Representation)
|
# 高級中間表示(HIR, High-level Intermediate Representation)
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/hir.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
HIR 是 Erg 編譯器從 AST 生成的結構
|
HIR 是 Erg 編譯器從 AST 生成的結構
|
||||||
此結構包含源代碼中每個表達式的完整類型信息,并且在語法上已脫糖
|
此結構包含源代碼中每個表達式的完整類型信息,并且在語法上已脫糖
|
||||||
AST與源代碼一一對應(純文本),但是HIR去掉了不必要的代碼信息,添加了省略的類型信息,所以HIR可以轉換為源代碼很難恢復
|
AST與源代碼一一對應(純文本),但是HIR去掉了不必要的代碼信息,添加了省略的類型信息,所以HIR可以轉換為源代碼很難恢復
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/index.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 類型推斷算法
|
# 類型推斷算法
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/inference.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
> __Warning__:此部分正在編輯中,可能包含一些錯誤
|
> __Warning__:此部分正在編輯中,可能包含一些錯誤
|
||||||
|
|
||||||
顯示了下面使用的符號
|
顯示了下面使用的符號
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# `erg` 概覽
|
# `erg` 概覽
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/overview.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
我們將介紹每一層的功能以及特別重要的功能和方法。
|
我們將介紹每一層的功能以及特別重要的功能和方法。
|
||||||
|
|
||||||
## 1. 詞法分析
|
## 1. 詞法分析
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 解析 Erg 語言
|
# 解析 Erg 語言
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/parsing.md&commit_hash=51de3c9d5a9074241f55c043b9951b384836b258)
|
||||||
|
|
||||||
## 空格的處理
|
## 空格的處理
|
||||||
|
|
||||||
Erg語法的一個特點是它對空間敏感。
|
Erg語法的一個特點是它對空間敏感。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 篩子類型
|
# 篩子類型
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/refinement_subtyping.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{I: Int | I >= 0}
|
{I: Int | I >= 0}
|
||||||
{S: StrWithLen N | N >= 1}
|
{S: StrWithLen N | N >= 1}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 解決補丁方法
|
# 解決補丁方法
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/trait_method_resolving.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
`Nat` 是零個或多個`Int`,`Int` 的子類型。
|
`Nat` 是零個或多個`Int`,`Int` 的子類型。
|
||||||
`Nat` 在 Python 類層次結構中不存在。 我想知道 Erg 是如何解決這個補丁方法的?
|
`Nat` 在 Python 類層次結構中不存在。 我想知道 Erg 是如何解決這個補丁方法的?
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Erg 代碼如何轉譯成 Python 代碼?
|
# Erg 代碼如何轉譯成 Python 代碼?
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/transpile.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
準確地說,Erg 代碼被轉譯為 Python 字節碼。
|
準確地說,Erg 代碼被轉譯為 Python 字節碼。
|
||||||
但是,由于 Python 字節碼幾乎可以重構為 Python 代碼,因此這里以等效的 Python 代碼為例。
|
但是,由于 Python 字節碼幾乎可以重構為 Python 代碼,因此這里以等效的 Python 代碼為例。
|
||||||
順便說一句,這里展示的示例是低優化級別。
|
順便說一句,這里展示的示例是低優化級別。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 歸一化
|
# 歸一化
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/compiler/type_var_normalization.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
* Erg 的類型參數規范化基于 SymPy 的簡化函數。
|
* Erg 的類型參數規范化基于 SymPy 的簡化函數。
|
||||||
|
|
||||||
例如,當您定義 `concat: |T, M, N|([T; M], [T; N] -> [T; M+N])` 時,您可以匹配類型變量和參數而無需實例化它們.必須作出判斷。
|
例如,當您定義 `concat: |T, M, N|([T; M], [T; N] -> [T; M+N])` 時,您可以匹配類型變量和參數而無需實例化它們.必須作出判斷。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 分支機構命名和運營策略
|
# 分支機構命名和運營策略
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/branches.md&commit_hash=a711efa99b325ba1012f6897e7b0e2bdb947d8a1)
|
||||||
|
|
||||||
## main
|
## main
|
||||||
|
|
||||||
* 主要開發分支
|
* 主要開發分支
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# `erg` 構建功能
|
# `erg` 構建功能
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/build_features.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
## 調試
|
## 調試
|
||||||
|
|
||||||
進入調試模式。結果,Erg 內部的行為順序顯示在日志中。
|
進入調試模式。結果,Erg 內部的行為順序顯示在日志中。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Erg存儲表結構
|
# Erg存儲表結構
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/directories.md&commit_hash=a711efa99b325ba1012f6897e7b0e2bdb947d8a1)
|
||||||
|
|
||||||
```console
|
```console
|
||||||
└─┬ assets:圖片等
|
└─┬ assets:圖片等
|
||||||
├─ CODE_OF_CONDUCT:行為準則
|
├─ CODE_OF_CONDUCT:行為準則
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 格式
|
# 格式
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/doc_guideline.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
任何不符合以下規則的文件都將得到更正。
|
任何不符合以下規則的文件都將得到更正。
|
||||||
|
|
||||||
* 以某種語氣寫代碼注釋或內部文檔。
|
* 以某種語氣寫代碼注釋或內部文檔。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 開發環境
|
# 開發環境
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/env.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
## 你需要安裝什么
|
## 你需要安裝什么
|
||||||
|
|
||||||
* Rust(與 rustup 一起安裝)
|
* Rust(與 rustup 一起安裝)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Erg design's "Why" and Answers
|
# Erg design's "Why" and Answers
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/faq_syntax.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
## 當我們有所有權系統時,為什么要與 GC 共存?
|
## 當我們有所有權系統時,為什么要與 GC 共存?
|
||||||
|
|
||||||
因為 Erg 推出所有權系統的動機并不是為了 Rust 那樣的“不依賴 GC 的內存管理”。最初,由于 Erg 是一種語言,目前使用 Python VM,因此最終仍使用 GC。Erg 引入產權系統的目標是“可變狀態的局部化”。在 Erg 中,可變對象具有所有權概念。這是根據共享可變狀態容易成為 bug 的溫床,甚至是類型安全性的侵犯(詳見)來判斷的。
|
因為 Erg 推出所有權系統的動機并不是為了 Rust 那樣的“不依賴 GC 的內存管理”。最初,由于 Erg 是一種語言,目前使用 Python VM,因此最終仍使用 GC。Erg 引入產權系統的目標是“可變狀態的局部化”。在 Erg 中,可變對象具有所有權概念。這是根據共享可變狀態容易成為 bug 的溫床,甚至是類型安全性的侵犯(詳見)來判斷的。
|
||||||
|
@ -48,7 +50,6 @@ assert S.i == Int
|
||||||
|
|
||||||
在 Erg 中,運算符使你可以在不太注意錯誤的情況下編寫。
|
在 Erg 中,運算符使你可以在不太注意錯誤的情況下編寫。
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
read_file!() =
|
read_file!() =
|
||||||
f = open!("foo.txt")? # 如果失敗則立即返回錯誤,所以 f 是文件類型
|
f = open!("foo.txt")? # 如果失敗則立即返回錯誤,所以 f 是文件類型
|
||||||
|
@ -77,7 +78,6 @@ Python 的庫中有一些類設計為繼承,如果完全取消繼承,這些
|
||||||
|
|
||||||
默認情況下,指向結構托盤會使類型指定變得復雜,并且可能會混合程序員的非預期行為。
|
默認情況下,指向結構托盤會使類型指定變得復雜,并且可能會混合程序員的非預期行為。
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# 如果 T 是結構特征的子類型...
|
# 如果 T 是結構特征的子類型...
|
||||||
# f: |T <: Structural Trait {.`_+_` = Self.(Self) -> Self; .`_-_` = Self.(Self) -> Self}| (T, T) -> T
|
# f: |T <: Structural Trait {.`_+_` = Self.(Self) -> Self; .`_-_` = Self.(Self) -> Self}| (T, T) -> T
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 多語言錯誤信息
|
# 多語言錯誤信息
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/i18n_messages.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
Erg 正在推動消息(開始、選項、文檔、提示、警告、錯誤消息等)的多語言化。如果你不熟悉 Rust 或 Erg,也可以參與此項目。請務必配合。
|
Erg 正在推動消息(開始、選項、文檔、提示、警告、錯誤消息等)的多語言化。如果你不熟悉 Rust 或 Erg,也可以參與此項目。請務必配合。
|
||||||
|
|
||||||
以下是多語種方法的說明。
|
以下是多語種方法的說明。
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/index.md&commit_hash=7d43acdf0e2b71528b038b9a8e70be6c93831f96)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Rust 代碼指南
|
# Rust 代碼指南
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/rust_code_guideline.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
## 本地規則
|
## 本地規則
|
||||||
|
|
||||||
* 使用 `log!` 進行調試輸出(使用 `println!` 等進行輸出處理,這也是發布所必需的)。
|
* 使用 `log!` 進行調試輸出(使用 `println!` 等進行輸出處理,這也是發布所必需的)。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 詞匯表
|
# 詞匯表
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/terms.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
## 象征
|
## 象征
|
||||||
|
|
||||||
### !
|
### !
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 術語統一
|
# 術語統一
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/dev_guide/unify_terms.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
## 可訪問性,可見性
|
## 可訪問性,可見性
|
||||||
|
|
||||||
使用可見性。
|
使用可見性。
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
# Erg常見問題
|
# Erg常見問題
|
||||||
|
|
||||||
此常見問題解答適用于一般 Erg 初學者。
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/faq_general.md&commit_hash=eccd113c1512076c367fb87ea73406f91ff83ba7)
|
||||||
對于個別(常見)技術問題,請參閱 [此處](./faq_technical.md) 了解個別(常見)技術問題,以及
|
|
||||||
[這里](./dev_guide/faq_syntax.md) 了解更多信息。
|
This FAQ is intended for the general Erg beginner.
|
||||||
|
For individual (common) technical issues, please refer to [here](./faq_technical.md) for individual (common) technical issues, and
|
||||||
|
[Here](./dev_guide/faq_syntax.md) for more information.
|
||||||
|
|
||||||
## Erg 是 Python 兼容語言是什么意思?
|
## Erg 是 Python 兼容語言是什么意思?
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# 技術常見問題
|
# 技術常見問題
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/faq_technical.md&commit_hash=c120700585fdb1d655255c8e2817bb13cc8d369e)
|
||||||
|
|
||||||
本節回答有關使用 Erg 語言的技術問題。換句話說,它包含以 What 或 Which 開頭的問題,以及可以用 Yes/No 回答的問題。
|
本節回答有關使用 Erg 語言的技術問題。換句話說,它包含以 What 或 Which 開頭的問題,以及可以用 Yes/No 回答的問題。
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Python 的改進
|
# Python 的改進
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/improved_points.md&commit_hash=eccd113c1512076c367fb87ea73406f91ff83ba7)
|
||||||
|
|
||||||
## 執行靜態分析(靜態類型檢查、變量和屬性檢查)
|
## 執行靜態分析(靜態類型檢查、變量和屬性檢查)
|
||||||
|
|
||||||
靜態類型檢查的好處現在怎么強調都不為過,但是檢查變量和屬性的存在也是相當重要的一部分。
|
靜態類型檢查的好處現在怎么強調都不為過,但是檢查變量和屬性的存在也是相當重要的一部分。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 索引
|
# 索引
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/index.md&commit_hash=eccd113c1512076c367fb87ea73406f91ff83ba7)
|
||||||
|
|
||||||
## [API/](./API/index.md)
|
## [API/](./API/index.md)
|
||||||
|
|
||||||
本節介紹 Erg 的內置或標準庫提供的子程序、類型、常量等的規范。
|
本節介紹 Erg 的內置或標準庫提供的子程序、類型、常量等的規范。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 從 Python 遷移到 Erg 的提示
|
# 從 Python 遷移到 Erg 的提示
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/migration_from_py.md&commit_hash=06f8edc9e2c0cee34f6396fd7c64ec834ffb5352)
|
||||||
|
|
||||||
## 我想將字符串轉換為 int 等。
|
## 我想將字符串轉換為 int 等。
|
||||||
|
|
||||||
使用 `Str` 類的 `parse` 方法。 它返回一個 `Result` 類型。
|
使用 `Str` 類的 `parse` 方法。 它返回一個 `Result` 類型。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Python 字節碼指令
|
# Python 字節碼指令
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/python/bytecode_instructions.md&commit_hash=d15cbbf7b33df0f78a575cff9679d84c36ea3ab1)
|
||||||
|
|
||||||
Python 字節碼變量操作命令通過 名稱索引(名稱索引)訪問。 這是為了在 Python 中實現動態變量訪問(可以使用 eval 等作為字符串訪問)。
|
Python 字節碼變量操作命令通過 名稱索引(名稱索引)訪問。 這是為了在 Python 中實現動態變量訪問(可以使用 eval 等作為字符串訪問)。
|
||||||
一條指令為 2 個字節,指令和參數以 little endian 形式存儲。
|
一條指令為 2 個字節,指令和參數以 little endian 形式存儲。
|
||||||
不帶參數的指令也使用 2 個字節(參數部分為 0)。
|
不帶參數的指令也使用 2 個字節(參數部分為 0)。
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Python bytecode specification
|
# Python bytecode specification
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/python/bytecode_specification.md&commit_hash=9f6a4a43fcf7e4f58cabe6e5a7546820fd9f5ff4)
|
||||||
|
|
||||||
## Format
|
## Format
|
||||||
|
|
||||||
* 0~3 byte(u32): magic number (see common/bytecode.rs for details)
|
* 0~3 byte(u32): magic number (see common/bytecode.rs for details)
|
||||||
|
@ -70,7 +72,6 @@
|
||||||
* 1~4 byte: length of string
|
* 1~4 byte: length of string
|
||||||
* 5~ byte: payload
|
* 5~ byte: payload
|
||||||
|
|
||||||
|
|
||||||
# Python 字節碼規范
|
# Python 字節碼規范
|
||||||
|
|
||||||
## 格式
|
## 格式
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Python 類系統(與 Erg 比較)
|
# Python 類系統(與 Erg 比較)
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/python/class_system.md&commit_hash=51de3c9d5a9074241f55c043b9951b384836b258)
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
||||||
方法可以被前向引用,但這不是一種特殊的技術。
|
方法可以被前向引用,但這不是一種特殊的技術。
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/python/index.md&commit_hash=9f6a4a43fcf7e4f58cabe6e5a7546820fd9f5ff4)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# 基本
|
# 基本
|
||||||
|
|
||||||
|
[](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/syntax/00_basic.md&commit_hash=51de3c9d5a9074241f55c043b9951b384836b258)
|
||||||
|
|
||||||
> __Warning__:本文檔不完整。 它未經校對(樣式、正確鏈接、誤譯等)。 此外,Erg 的語法可能在版本 0.* 期間發生破壞性更改,并且文檔可能沒有相應更新。 請事先了解這一點。
|
> __Warning__:本文檔不完整。 它未經校對(樣式、正確鏈接、誤譯等)。 此外,Erg 的語法可能在版本 0.* 期間發生破壞性更改,并且文檔可能沒有相應更新。 請事先了解這一點。
|
||||||
> 如果您在本文檔中發現任何錯誤,請報告至 [此處的表單](https://forms.gle/HtLYRfYzWCAaeTGb6) 或 [GitHub repo](https://github.com/mtshiba/TheErgBook/issues/new )。 我們將不勝感激您的建議。
|
> 如果您在本文檔中發現任何錯誤,請報告至 [此處的表單](https://forms.gle/HtLYRfYzWCAaeTGb6) 或 [GitHub repo](https://github.com/mtshiba/TheErgBook/issues/new )。 我們將不勝感激您的建議。
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue