diff --git a/doc/EN/faq_technical.md b/doc/EN/faq_technical.md index 5482213b..b38de284 100644 --- a/doc/EN/faq_technical.md +++ b/doc/EN/faq_technical.md @@ -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 " ") +``` diff --git a/doc/JA/faq_technical.md b/doc/JA/faq_technical.md index e9e09c3a..64cab197 100644 --- a/doc/JA/faq_technical.md +++ b/doc/JA/faq_technical.md @@ -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 " ") +```