mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
doc: update faq_technical.md
This commit is contained in:
parent
2c1a6ffff2
commit
032b3afba2
2 changed files with 18 additions and 0 deletions
|
@ -31,3 +31,12 @@ Procedure `p!` and mutable type `T!` can cause side effects, but if the return v
|
|||
|
||||
A: The Erg API is typed as closely as possible to the Python API specification, but there are some cases that cannot be fully expressed.
|
||||
Also, input that is valid according to the specification but deemed undesirable (for example, inputting a float when an int should be inputted) may be treated as a type error at the discretion of the Erg development team.
|
||||
|
||||
## Why doesn't Tuple have a constructor (`__call__`)?
|
||||
|
||||
Erg tuples must have a compile-time length. Therefore, a tuple is constructed almost only by a tuple literal.
|
||||
If the length is not known until runtime, an immutable array (`Array`) can be used instead.
|
||||
|
||||
```erg
|
||||
arr = Array map(int, input!().split " ")
|
||||
```
|
||||
|
|
|
@ -33,3 +33,12 @@ A: `!`は副作用の産物につけるマーカーではなく、副作用を
|
|||
|
||||
A: ErgのAPIはなるべくPythonのAPIの仕様に忠実に型付けられていますが、どうしても表現しきれないケースもあります。
|
||||
また、仕様上有効でも望ましくないと判断した入力(例えば、intを入力すべきところでfloatを入力してもよい仕様など)は、Erg開発チームの判断により型エラーとする可能性があります。
|
||||
|
||||
## Tupleにはなぜコンストラクタ(`__call__`)がないのですか?
|
||||
|
||||
Ergのタプルは長さがコンパイル時に決まっている必要があります。そのため、タプルを構築する手段はほぼリテラルのみです。
|
||||
長さが実行まで不定の場合、代わりに不変配列(`Array`)を使うことになります。Ergの不変配列はPythonのタプルとほぼ同じです。
|
||||
|
||||
```erg
|
||||
arr = Array map(int, input!().split " ")
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue