diff --git a/compiler/erg_common/python_util.rs b/compiler/erg_common/python_util.rs index 4548b7ac..e0d4041d 100644 --- a/compiler/erg_common/python_util.rs +++ b/compiler/erg_common/python_util.rs @@ -373,8 +373,8 @@ pub fn which_python() -> String { if res.is_empty() { println!("python not found"); std::process::exit(1); - } else if res.contains("pyenv") { - println!("cannot use pyenv"); + } else if res.contains("pyenv") && cfg!(windows) { + println!("cannot use pyenv-win"); // because pyenv-win does not support `-c` option std::process::exit(1); } res diff --git a/doc/EN/dev_guide/env.md b/doc/EN/dev_guide/env.md index 5f9b2e56..d10b2e43 100644 --- a/doc/EN/dev_guide/env.md +++ b/doc/EN/dev_guide/env.md @@ -19,4 +19,3 @@ The checks may fail on the first run even if there are no bugs, in which case yo * Editor: Visual Studio Code * VSCode extensions: Rust-analyzer, GitLens, Git Graph, GitHub Pull Requests and Issues, Markdown All in One, markdownlint * OS: Windows 10/11 | Ubuntu 20.04/22.04 | Mac OS Monterey -* Others: mold diff --git a/doc/EN/syntax/00_basic.md b/doc/EN/syntax/00_basic.md index aa606a31..996a986a 100644 --- a/doc/EN/syntax/00_basic.md +++ b/doc/EN/syntax/00_basic.md @@ -79,10 +79,10 @@ The code after `#` is ignored as a comment. Use this to explain the intent of th ```python # Comment # `#` and after are ignored until a new line is inserted -# [ +#[ Multi-line comment Treated as a comment all the way up to the corresponding `]#` -]# +]# ``` ## Expressions, separators diff --git a/doc/EN/syntax/01_literal.md b/doc/EN/syntax/01_literal.md index 2bcee327..8b52a98b 100644 --- a/doc/EN/syntax/01_literal.md +++ b/doc/EN/syntax/01_literal.md @@ -14,6 +14,8 @@ 0.00, -0.0, 0.1, 400.104, ... ``` +Note that the Ratio type is different from the Float type; the API is the same, but there are differences in the accuracy and efficiency of the calculation results. + If a `Ratio` literal has an integer or decimal part of `0`, you can omit the `0`. ```python @@ -62,7 +64,7 @@ Each of these literals has its own documentation describing them separately, so ### [Array Literal](./10_array.md) ```python -[], [1], [1, 2, 3], ["1", "2",], [1, "1", True, [1]], ... +[], [1], [1, 2, 3], ["1", "2",], ... ``` ### [Tuple Literal](./11_tuple.md) @@ -86,7 +88,7 @@ Each of these literals has its own documentation describing them separately, so ### [Set Literal](./14_set.md) ```python -{}, {1}, {1, 2, 3}, {"1", "2", "1"}, {1, "1", True, [1]} ... +{}, {1}, {1, 2, 3}, {"1", "2", "1"}, ... ``` As a difference from `Array` literals, duplicate elements are removed in `Set`. @@ -112,10 +114,11 @@ None ## Range Object ```python -assert 0..5 == {1, 2, 3, 4, 5} assert 0..10 in 5 assert 0..<10 notin 10 assert 0..9 == 0..<10 +assert (0..5).to_set() == {1, 2, 3, 4, 5} +assert "a" in "a".."z" ``` ## Float Object @@ -130,10 +133,10 @@ Float objects are constructed by multiplying a `Ratio` object by `f64`, which is ## Complex Object ```python -1+2im, 0.4-1.2im, 0im, im +1+2Im, 0.4-1.2Im, 0Im, Im ``` -A `Complex` object is simply an arithmetic combination of an imaginary unit object, `im`. +A `Complex` object is simply an arithmetic combination of an imaginary unit object, `Im`. ## *-less multiplication diff --git a/doc/JA/dev_guide/env.md b/doc/JA/dev_guide/env.md index 90715c92..caee88e6 100644 --- a/doc/JA/dev_guide/env.md +++ b/doc/JA/dev_guide/env.md @@ -21,4 +21,3 @@ pre-commitを使ってclippyのチェックやテストを自動で行わせて * エディタ: Visual Studio Code * VSCode拡張機能: Rust-analyzer, GitLens, Git Graph, GitHub Pull Requests and Issues, Markdown All in One, markdownlint * OS: Windows 10/11 | Ubuntu 20.04/22.04 | MacOS Monterey -* その他: mold diff --git a/doc/JA/syntax/00_basic.md b/doc/JA/syntax/00_basic.md index 9090b794..b3533b8a 100644 --- a/doc/JA/syntax/00_basic.md +++ b/doc/JA/syntax/00_basic.md @@ -60,10 +60,10 @@ hello, world ```python # コメント ## `#`以降は改行されるまで無視されるため、`#`は何個でも使用できる -# [ +#[ 複数行コメント -対応する# `[`から`]#`のところまでがコメントとして扱われる -]# +対応する`#[`から`]#`のところまでがコメントとして扱われる +]# ``` ## 式、セパレータ diff --git a/doc/JA/syntax/01_literal.md b/doc/JA/syntax/01_literal.md index 9568dbb0..eb234312 100644 --- a/doc/JA/syntax/01_literal.md +++ b/doc/JA/syntax/01_literal.md @@ -9,10 +9,11 @@ ```python 0, -0, 1, -1, 2, -2, 3, -3, ... ``` -0未満の数値は`Int`リテラルとして型が解釈されます。 -> __Note__: また、`Int`リテラルの部分型として`Nat`リテラルが存在します。 -> 0以上の数値は`Nat`リテラルとして型が解釈されます。 +整数(Int)リテラルはInt型のオブジェクトです。 + +> __Note__: `Int`型の部分型として`Nat`型が存在します。 +> 0以上の数値は`Nat`型とも解釈できます。 ### 有理数リテラル(Ratio Literal) @@ -20,6 +21,7 @@ 0.00, -0.0, 0.1, 400.104, ... ``` +有理数を表すリテラルです。専ら小数として表現されますが、内部的には分数として扱われます。 `Ratio`リテラルで整数部分または小数部分が`0`のときは、その`0`を省略できます。 ```python @@ -68,7 +70,7 @@ assert 1e-10 == 0.0000000001 ### [配列リテラル(Array Literal)](./10_array.md) ```python -[], [1], [1, 2, 3], ["1", "2",], [1, "1", True, [1]], ... +[], [1], [1, 2, 3], ["1", "2",], ... ``` ### [組リテラル(Tuple Literal)](./11_tuple.md) @@ -92,7 +94,7 @@ assert 1e-10 == 0.0000000001 ### [集合リテラル(Set Literal)](./14_set.md) ```python -{}, {1}, {1, 2, 3}, {"1", "2", "1"}, {1, "1", True, [1]} ... +{}, {1}, {1, 2, 3}, {"1", "2", "1"}, ... ``` `Array`リテラルとの違いとして、`Set`では重複する要素が取り除かれます。 @@ -109,21 +111,34 @@ assert {1, 2, 1} == {1, 2} True, False ``` +真偽値オブジェクトはBool型の単なるシングルトン(ダブルトン?)です。 +Pythonからの伝統により、`Bool`型は`Int`型ないし`Nat`型のサブタイプとなります。 +すなわち、`True`は`1`、`False`は`0`と解釈できます。 + +```python +assert True * 2 == 1 +``` + ### Noneオブジェクト ```python None ``` +`NoneType`型のシングルトンです。 + ## 範囲オブジェクト(Range Object) ```python -assert 0..5 == {1, 2, 3, 4, 5} assert 0..10 in 5 assert 0..<10 notin 10 assert 0..9 == 0..<10 +assert (0..5).to_set() == {1, 2, 3, 4, 5} +assert "a" in "a".."z" ``` +Pythonの`range`とは異なり、IntだけでなくStrオブジェクトなども範囲として扱うことができます。 + ## 浮動小数点数オブジェクト(Float Object) ```python @@ -132,14 +147,15 @@ assert 0.0f32 == 0.0f64 ``` `Ratio`オブジェクトに`Float 64`の単位オブジェクトである`f64`を乗算したものです。 +誤差が生じる可能性がありますが、`Ratio`よりも高速に計算できます。 ## 複素数オブジェクト(Complex Object) ```python -1+2im, 0.4-1.2im, 0im, im +1+2Im, 0.4-1.2Im, 0Im, Im ``` -`Complex`オブジェクトは、単に虚数単位オブジェクトである`im`との演算の組み合わせで表します。 +`Complex`オブジェクトは、単に虚数単位オブジェクトである`Im`との演算の組み合わせで表します。 ## *-less multiplication diff --git a/doc/zh_CN/dev_guide/env.md b/doc/zh_CN/dev_guide/env.md index 65b0ae91..c402a18e 100644 --- a/doc/zh_CN/dev_guide/env.md +++ b/doc/zh_CN/dev_guide/env.md @@ -18,4 +18,3 @@ * 编辑器: Visual Studio Code * VSCode 扩展: Rust-analyzer、GitLens、Git Graph、GitHub Pull Requests and Issues、Markdown All in One、markdownlint * 操作系统: Windows 10/11 | Ubuntu 20.04/22.04 | Mac OS Monterey -* 其他: mold diff --git a/doc/zh_CN/syntax/00_basic.md b/doc/zh_CN/syntax/00_basic.md index 6c100b5f..43a8e386 100644 --- a/doc/zh_CN/syntax/00_basic.md +++ b/doc/zh_CN/syntax/00_basic.md @@ -42,7 +42,7 @@ Erg 代码称为脚本。脚本可以以文件格式 (.er) 保存和执行 ## REPL/文件执行 -要启动 REPL,只需键入: +要启动 REPL,只需键入: ```sh > erg @@ -75,10 +75,10 @@ hello, world! ```python # Comment # `#` and after are ignored until a new line is inserted -# [ +#[ Multi-line comment Treated as a comment all the way up to the corresponding `]#` -]# +]# ``` ## 表达式,分隔符 diff --git a/doc/zh_CN/syntax/01_literal.md b/doc/zh_CN/syntax/01_literal.md index 13dc6d02..ae0aad8f 100644 --- a/doc/zh_CN/syntax/01_literal.md +++ b/doc/zh_CN/syntax/01_literal.md @@ -132,10 +132,10 @@ assert 0.0f32 == 0.0f64 ## Complex 对象 ```python -1+2im, 0.4-1.2im, 0im, im +1+2Im, 0.4-1.2Im, 0Im, Im ``` -一个"复杂"对象只是一个虚数单位对象`im`的算术组合 +一个"复杂"对象只是一个虚数单位对象`Im`的算术组合 ## *-less 乘法 diff --git a/doc/zh_TW/dev_guide/env.md b/doc/zh_TW/dev_guide/env.md index a15832cf..5026a90f 100644 --- a/doc/zh_TW/dev_guide/env.md +++ b/doc/zh_TW/dev_guide/env.md @@ -18,4 +18,3 @@ * 編輯器: Visual Studio Code * VSCode 擴展: Rust-analyzer、GitLens、Git Graph、GitHub Pull Requests and Issues、Markdown All in One、markdownlint * 操作系統: Windows 10/11 | Ubuntu 20.04/22.04 | Mac OS Monterey -* 其他: mold diff --git a/doc/zh_TW/syntax/00_basic.md b/doc/zh_TW/syntax/00_basic.md index 076958ca..7aeecaa2 100644 --- a/doc/zh_TW/syntax/00_basic.md +++ b/doc/zh_TW/syntax/00_basic.md @@ -42,7 +42,7 @@ Erg 代碼稱為腳本。腳本可以以文件格式 (.er) 保存和執行 ## REPL/文件執行 -要啟動 REPL,只需鍵入: +要啟動 REPL,只需鍵入: ```sh > erg @@ -75,10 +75,10 @@ hello, world! ```python # Comment # `#` and after are ignored until a new line is inserted -# [ +#[ Multi-line comment Treated as a comment all the way up to the corresponding `]#` -]# +]# ``` ## 表達式,分隔符 diff --git a/doc/zh_TW/syntax/01_literal.md b/doc/zh_TW/syntax/01_literal.md index e8fec79f..3098ef17 100644 --- a/doc/zh_TW/syntax/01_literal.md +++ b/doc/zh_TW/syntax/01_literal.md @@ -132,10 +132,10 @@ assert 0.0f32 == 0.0f64 ## Complex 對象 ```python -1+2im, 0.4-1.2im, 0im, im +1+2Im, 0.4-1.2Im, 0Im, Im ``` -一個"復雜"對象只是一個虛數單位對象`im`的算術組合 +一個"復雜"對象只是一個虛數單位對象`Im`的算術組合 ## *-less 乘法