Ada 202x (50日目) - 6月13日の電子会議の結果 =========================================== .. post:: Jun 20, 2020 :tags: ada, ada_2022 .. |ZWSP| unicode:: U+200B .. ZERO WIDTH SPACE :trim: `6月13日に行われた電子会議の議事録 `_\ が公開されました。 内部イテレータ(procedural iterator)の制限 ----------------------------------------- ``Allows_Exit`` や ``Parallel_Iterator`` はサブプログラムを指すaccess型の引数を複数持つサブプログラムには指定できなくなりました。 どの引数に対する性質かを特定できないためです。 また ``Parallel_Iterator`` が呼び出すサブプログラムが本当にリエントラントなのかチェックするための ``Parallel_Calls`` アスペクトが追加されました。 Parallel_Callsアスペクト ++++++++++++++++++++++++ ``Parallel_Calls`` が指定されたサブプログラムはリエントラント(再入可能)でなければなりません。 .. code-block:: ada declare procedure Parallel_Countdown (N : in Natural; P : not null access procedure (I : in Positive)) with Parallel_Iterator is begin parallel for I in reverse 1 .. N loop P (I); end loop; end Countdown; X : array (1 .. 10) of Boolean := (others => False); begin parallel for (I : in Positive) of Parallel_Countdown (10) loop X (I) := True; end loop; この例はこのように展開されます。 .. code-block:: ada declare -- 省略 X : array (1 .. 10) of Boolean := (others => False); procedure Loop_Body (I : in Positive) with Parallel_Calls is begin X (I) := True; end Loop_Body; begin Parallel_Countdown (10, Loop_Body'Access); リエントラントかどうかのチェックはpragma ``Conflict_Check_Policy`` によります。 配列の各要素へのアクセスがどう推定されるかよく理解しておらず申し訳ないのですが、もし ``X`` 全体へのoutアクセスと見做されるなら ``Loop_Body`` の呼び出し同士が衝突してしまいますので ``pragma Conflict_Check_Policy (No_Conflict_Checks);`` で抑制することが必要になるかもしれません。 外部イテレータ(Parallel_Iterator)の制限 --------------------------------------- こちらは同じ ``Parallel_Iterator`` でも外部イテレータの方の制限です。 定義へのリンクを再掲しておきます。 | http://www.ada-auth.org/standards/2xrm/html/RM-5-5-1.html#p4.1 チャンクありの ``First``/``Next`` は例外を送出してはいけない、異なるチャンク番号に対して重複した範囲を返してはならない、等の制限が追加されました。 固定小数点型の属性 ------------------ 浮動小数点型にあって固定小数点型にない関数形式の属性を実装依存で実装しても良いことになりました。 ``'Floor`` 、 ``'Ceiling`` 、 ``'Rounding`` 、 ``'Unbiased_Rounding`` 、 ``'Machine_Rounding`` 、 ``'Truncation`` が該当します。 実装依存なら勝手に実装しても良さそうなものですが、実装依存の属性は言語が定義した属性と同じ名前を使えないというルールがあります。 匿名のaccess型のdiscriminantのAccessibility_Check ------------------------------------------------- 匿名のaccess型を返す関数には行われていた静的な ``Accessibility_Check`` がdiscriminantに対して見逃されていたケースがあり、修正されました。 Full_Access_Onlyアスペクト -------------------------- ``Volatile`` なrecord型のオブジェクトをアクセスする時は常に全体をアクセスするようにする ``Full_Access_Only`` アスペクトが追加されました。 ``Independent_Components`` の逆ですね。 Default_Valueとoutパラメータでの変換 ------------------------------------ :doc:`49日目 `\ でも触れましたように、 ``Default_Value`` を持つ型のoutパラメータは実際にはin outです。 ``Default_Value`` を持つ型の変数を変換で ``Default_Value`` を持たないout引数に渡してしまいますと ``Default_Value`` を持つ型の未初期化変数を作り出せてしまいます。 このような呼び出しの中での変換が禁止されます。 .. code-block:: ada declare procedure Uninitialize (X : out Integer) is begin null; end Uninitialize; type D is new Integer with Default_Value => 0; begin Uninitialize (Integer (D)); -- error ``Uninitialize`` の仮引数 ``X`` は ``Default_Value`` を持たない本物のoutパラメータですので中で代入しなければ未初期化値が返ります。 access型のnon nullの有無や指す先の制約による違いについても同様の変更が提案されていて、そちらは詰められている途中です。 delta aggregate式のタグ ----------------------- タグ付き型の値をdelta aggregateで更新した場合にタグは元の値のものを使うことになっていました。 .. code-block:: ada declare type T is tagged record E, F : Integer; end record; function Update_E1 (X : in out T) return T'Class is begin return (X with delta E => X.E + 1); end Update_E1; type D is new T with record G : Integer; end record; V : D := D'(E => 1, F => 2, G => 3); R : T'Class := Update_E1 (V); -- D'(E => 2, F => 2, G => 3) begin if R in D then -- True null; end if; しかし、式の代入先がclass-wide型ではない場合に型が合わなくなります。 .. code-block:: ada declare -- 省略 function Update_E2 (X : in out T) return T'Class is Temporary : T := (X with delta E => X.E + 1); -- TにDを代入しようとしている begin return Temporary; end Update_E2; -- 省略 R : T'Class := Update_E1 (V); -- Tag_Error このため求められている型がclass-wide型ではない場合はaggregate式自体の型になるよう修正されました。 .. code-block:: ada declare -- 省略 function Update_E2 (X : in out T) return T'Class is Temporary : T := (X with delta E => X.E + 1); -- Tになる begin return Temporary; end Update_E2; -- 省略 R : T'Class := Update_E2 (V); -- T'(E => 2, F => 2); begin if R in D then -- False null; end if; Type_Invariant'Classの修正 -------------------------- ``Type_Invariant'Class`` を持つ型から派生した場合はその型を返す関数に加えてin outパラメータやout パラメータを持つ手続きも ``overriding`` しないといけません。 その際に該当するプリミティブが現在位置から不可視であっても ``overriding`` しないといけない不可能な文面になっていたのが修正されました。 値のrenames ----------- ついに値の ``renames`` が認められてしまいました。 .. code-block:: ada declare One renames 1.0; え!? ここに来てこんなのぶっ込んできます!? :doc:`36日目 `\ の話はなんだったんだ……。 :doc:`9日目 `\ と\ :doc:`36日目 `\ を修正しました。 Interfaces.Shift_Left |ZWSP| /Shift_Right |ZWSP| /Shift_Right_Arithmetic |ZWSP| /Rotate_Left |ZWSP| /Rotate_Right ----------------------------------------------------------------------------------------------------------------- staticになりました。 その他サンプルコード等の修正 ---------------------------- 例によってサンプルコード等の修正がひとつのAI(`AI12-0379-1`_)で行われています。 関連AI ------ - `AI12-0344-1`_ **Procedural iterator aspects** - `AI12-0354-1`_ **Semantics of Parallel_Iterators** - `AI12-0362-2`_ **Attributes for fixed point types** - `AI12-0363-1`_ **Fixes for Atomic and Volatile** - `AI12-0372-1`_ **Static accessibility of “master of the call”** - `AI12-0377-1`_ **View conversions and out parameters of types with Default_Value revisited** - `AI12-0379-1`_ **More presentation issues** - `AI12-0381-1`_ **Tag of a delta aggregate** - `AI12-0382-1`_ **Loosen type-invariant overriding requirements of AI12-0042-1** - `AI12-0383-1`_ **Renaming values** - `AI12-0385-1`_ **Predefined shifts should be static** .. _`AI12-0344-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0344-1.txt .. _`AI12-0354-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0354-1.txt .. _`AI12-0362-2`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0362-2.txt .. _`AI12-0363-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0363-1.txt .. _`AI12-0372-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0372-1.txt .. _`AI12-0377-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0377-1.txt .. _`AI12-0379-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0379-1.txt .. _`AI12-0381-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0381-1.txt .. _`AI12-0382-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0382-1.txt .. _`AI12-0383-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0383-1.txt .. _`AI12-0385-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0385-1.txt