Ada 202x (35日目) - 標準ライブラリ ================================== .. post:: Jan 04, 2020 :tags: ada, ada_2022 .. role:: strike 標準ライブラリの変更を俯瞰します。 今回は一覧したいため目次を付けておきます。 .. contents:: :local: 変更があったもの ---------------- 全体的に ``Nonblocking`` や ``Global`` 、事前条件/事後条件、 ``Allows_Exit`` 等のアスペクトが追加されました。 またいくつかの型は ``'Image`` 属性が返す文字列の書式も定められました。 Ada.Calendar.Time_Zones +++++++++++++++++++++++ ``Time_Offset`` の符号の意味が定められました。 日本のタイムゾーンをUTC+9と表記する時の符号と同じです。 Ada.Command_Line ++++++++++++++++ 各関数が返す文字列の ``'First`` は ``1`` だと定められました。 Ada.Containers.\* +++++++++++++++++ 標準コンテナは、同じコンテナオブジェクトでも異なるスレッドが異なる要素に同期なしにアクセスしても大丈夫と定められました。 また ``Parallel_Iterator`` / ``Parallel_Reversible_Iterator`` がサポートされました。 aggregate式がサポートされました。 ``Iterator_View`` アスペクトが指定されcontainer element iterator(``of`` 形式)のループが少し効率的になりました。 そのために各コンテナに入れ子のパッケージ ``Stable`` が追加されています。 コンテナの要素型が終了処理を必要とする場合、実際に終了処理が行われるタイミングは実装依存と定められました。 終了処理を行わないまま保持しておいて使い回すような実装も認めらた、というより ``Vectors`` を配列で実装した既存の実装は大体そんなものだった(わざわざ毎回placement new/delete的なことをしてない)のが追認されたことになります。 Ada.Directories +++++++++++++++ ``Simple_Name`` と ``Containing_Directory`` にルートディレクトリを渡した場合の挙動が定められました。 ``Simple_Name`` が与えられたルートディレクトリをそのまま返し、``Containing_Directory`` は ``Use_Error`` になります。 理由としてPOSIXコマンドの ``basename /`` が ``/`` になるからみたいに書かれてるのですけれども ``dirname /`` だって ``/`` になることにどなたも気付かれなかったのでしょうか……。 あ、動作自体はこれでいいと思います。 Ada.Synchronous_Task_Control ++++++++++++++++++++++++++++ 元々 ``Suspend_Until_True`` は同じオブジェクトを使って複数スレッドを同時に待たせることはできませんでした。 複数スレッドが同じオブジェクトを引数にして同時に呼び出した場合 ``Program_Error`` になると明確に定められました。 Ada.Task_Identification +++++++++++++++++++++++ ``Activation_Is_Complete`` に ``Null_Task_Id`` が渡された場合 ``Program_Error`` になると明確に定められました。 Interfaces ++++++++++ ``Shift_Left`` 、 ``Shift_Right`` 、``Shift_Right_Arithmetic`` 、``Rotate_Left`` 、``Rotate_Right`` で各型のビット数を超えてシフト/ローテートした時の挙動が定められました。 ``Shift_Left`` と ``Shift_Right`` は ``0`` になります。 ``Shift_Right_Arithmetic`` は全ビットが符号ビットと同じになります。 ``Rotate_Left`` と ``Rotate_Right`` はどれだけ大きなローテート幅が渡されても指定分ローテートします。 単純にCPUのシフト/ローテート命令を使っただけでは、型のビット数を超えたシフト/ローテートの挙動はCPUによってまちまちでした。 System.Storage_Pools ++++++++++++++++++++ ``Pure`` になりました。 ``Subpools`` は ``Preelaborate`` のままです。 System.Storage_Pools.Subpools +++++++++++++++++++++++++++++ 終了処理の順番が定められました。 割り当てられたオブジェクトの終了処理をメモリ解放よりも先に行います。 ``Root_Storage_Pool_With_Subpools`` が ``Preelaborable_Initialization`` になりました。 新しく追加されたライブラリ -------------------------- 翻訳単位ごと追加されたものです。 Ada.Containers.Bounded_Indefinite_Holders +++++++++++++++++++++++++++++++++++++++++ ``Indefinite_Holders`` の更にBounded版です。 追加の動的割り当てなしで固定サイズの領域に可変サイズの値を入れるためのコンテナです。 ``generic`` の引数として指定した ``Max_Element_Size_in_Storage_Elements`` を超える場合は ``Program_Error`` になります。 | http://www.ada-auth.org/standards/2xrm/html/RM-A-18-32.html Ada.Numerics.Big_Numbers ++++++++++++++++++++++++ Ada.Numerics.Big_Numbers.Big_Integers +++++++++++++++++++++++++++++++++++++ Ada.Numerics.Big_Numbers.Big_Reals ++++++++++++++++++++++++++++++++++ :doc:`21日目 `\ を参照。 Ada.Streams.Storage +++++++++++++++++++ Ada.Streams.Storage.Bounded +++++++++++++++++++++++++++ Ada.Streams.Storage.Unbounded +++++++++++++++++++++++++++++ :doc:`7日目 `\ を参照。 Ada.Strings.Text_Buffers ++++++++++++++++++++++++ Ada.Strings.Text_Buffers.Bounded ++++++++++++++++++++++++++++++++ Ada.Strings.Text_Buffers.Unbounded ++++++++++++++++++++++++++++++++++ :doc:`15日目 `\ を参照。 Ada.Wide_Command_Line +++++++++++++++++++++ Ada.Wide_Directories ++++++++++++++++++++ Ada.Wide_Environment_Variables ++++++++++++++++++++++++++++++ Ada.Wide_Wide_Command_Line ++++++++++++++++++++++++++ Ada.Wide_Wide_Directories +++++++++++++++++++++++++ Ada.Wide_Wide_Environment_Variables +++++++++++++++++++++++++++++++++++ :doc:`1日目 `\ を参照。 System.Atomic_Operations ++++++++++++++++++++++++ System.Atomic_Operations.Exchange +++++++++++++++++++++++++++++++++ System.Atomic_Operations.Integer_Arithmetic +++++++++++++++++++++++++++++++++++++++++++ System.Atomic_Operations.Modular_Arithmetic +++++++++++++++++++++++++++++++++++++++++++ System.Atomic_Operations.Test_And_Set +++++++++++++++++++++++++++++++++++++ :doc:`32日目 `\ を参照。 新しく追加されたエンティティ ---------------------------- 既存の翻訳単位の中に追加されたものです。 Ada.Containers.\* +++++++++++++++++ 各コンテナに入れ子のパッケージ ``Stable`` が追加されました。 :doc:`27日目 `\ を参照。 各コンテナに ``Has_Element`` 、 ``Next`` 、 ``Previous`` のオーバーロードが追加されました。 コンテナと ``Cursor`` の2つの引数を取ります。 各コンテナに ``Empty`` が追加されました。 :doc:`6日目 `\ を参照。 各コンテナに ``Equal_Element`` が追加されました。 要素型の ``"="`` 演算子の別名です。 各コンテナに ``Tampering_With_Cursors_Prohibited`` と ``Tampering_With_Elements_Prohibited`` が追加されました。 tampering checkを事前条件の中で書くためのものです。 Ada.Containers.Doubly_Linked_Lists ++++++++++++++++++++++++++++++++++ .. container:: strike ``Same_Object`` が追加されました。 2つのコンテナオブジェクトが同じかどうかを判定します。 ``'Has_Same_Storage`` 属性で充分だったのではという気はします。 | http://www.ada-auth.org/standards/2xrm/html/RM-A-18-3.html#p10.1 .. container:: strike ``Append_One`` が追加されました。 :doc:`52日目 `\ を参照。 Ada.Containers.Indefinite_Holders +++++++++++++++++++++++++++++++++ ``Swap`` が追加されました。 :doc:`48日目 `\ を参照。 Ada.Containers.Vectors ++++++++++++++++++++++ .. container:: strike ``Append_One`` が追加されました。 :doc:`6日目 `\ を参照。 ``Append`` 、 ``Prepend`` 、 ``Insert`` のオーバーロードされた ``Vector`` を追加する版が ``Append_Vector`` 、 ``Prepend_Vector`` 、 ``Insert_Vector`` として分離されました。 :doc:`53日目 `\ を参照。 Ada.Direct_IO +++++++++++++ Ada.Sequential_IO +++++++++++++++++ Ada.Streams.Stream_IO +++++++++++++++++++++ Ada.Text_IO +++++++++++ Ada.Wide_Text_IO ++++++++++++++++ Ada.Wide_Wide_Text_IO +++++++++++++++++++++ 入れ子のパッケージ ``Wide_File_Names`` と ``Wide_Wide_File_Names`` が追加されました。 :doc:`1日目 `\ を参照。 Ada.Dispatching.EDF +++++++++++++++++++ 相対時間でデッドラインを扱う多くのエンティティが追加されました。 :doc:`31日目 `\ を参照。 Ada.Iterator_Iterfaces ++++++++++++++++++++++ ``Parallel_Iterator`` と ``Parallel_Reversible_Iterator`` が追加されました。 :doc:`11日目 `\ を参照。 Ada.Numerics.Discrete_Random ++++++++++++++++++++++++++++ ``Random`` 関数に範囲をより絞り込めるオーバーロードが追加されました。 | http://www.ada-auth.org/standards/2xrm/html/RM-A-5-2.html#p20.1 Ada.Wide_Characters +++++++++++++++++++ ``Is_Basic`` と ``To_Basic`` が追加されました。 :doc:`28日目 `\ を参照。 ``Is_NFKC`` が追加されました。 :doc:`34日目 `\ を参照。 Ada.Wide_Wide_Characters ++++++++++++++++++++++++ ``Ada.Wide_Characters`` と同じ変更が加えられています。 Interfaces.C ++++++++++++ :strike:`bool` ``C_bool`` が追加されました。 :doc:`55日目 `\ を参照。 ターゲット環境のCコンパイラが ``long long`` をサポートしている場合にAdaコンパイラは ``long_long`` と ``unsigned_long_long`` を提供しないといけません。 Interfaces.Fortran ++++++++++++++++++ 入れ子のパッケージ ``Double_Precision_Complex_Types`` 、型 ``Double_Complex`` と ``Double_Imaginary`` が追加されました。 Fortranの ``complex(kind(0d0))`` に対応します。 | http://www.ada-auth.org/standards/2xrm/html/RM-B-5.html#p10.1 関連AI ------ - `AI12-0058-1`_ **The Fortran Annex needs updating to support Fortran 2008** - `AI12-0112-1`_ **Contracts for container operations** - `AI12-0144-1`_ **Make Discrete_Random more flexible** - `AI12-0171-1`_ **Ambiguity in Synchronous_Task_Control semantics** - `AI12-0184-1`_ **Long Long C Data Types** - `AI12-0196-1`_ **Concurrent access to Ada container libraries** - `AI12-0231-1`_ **Null_Task_Id and Activation_Is_Complete** - `AI12-0235-1`_ **System.Storage_Pools should be pure** - `AI12-0254-1`_ **Bounded_Indefinite_Holders** - `AI12-0258-1`_ **Containers and controlled element types** - `AI12-0259-1`_ **Lower bound of strings returned from Ada.Command_Line** - `AI12-0264-1`_ **Overshifting and overrotating** - `AI12-0286-1`_ **Allows_Exit aspect should be used on language-defined subprograms** - `AI12-0304-1`_ **Image attributes of language-defined types** - `AI12-0331-1`_ **Order of finalization of a subpool** - `AI12-0336-1`_ **Meaning of Time_Offset** - `AI12-0337-1`_ **Simple_Name("/") in Ada.Directories** .. _`AI12-0058-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0058-1.txt .. _`AI12-0112-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0112-1.txt .. _`AI12-0144-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0144-1.txt .. _`AI12-0171-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0171-1.txt .. _`AI12-0184-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0184-1.txt .. _`AI12-0196-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0196-1.txt .. _`AI12-0231-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0231-1.txt .. _`AI12-0235-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0235-1.txt .. _`AI12-0254-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0254-1.txt .. _`AI12-0258-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0258-1.txt .. _`AI12-0259-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0259-1.txt .. _`AI12-0264-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0264-1.txt .. _`AI12-0286-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0286-1.txt .. _`AI12-0304-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0304-1.txt .. _`AI12-0331-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0331-1.txt .. _`AI12-0336-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0336-1.txt .. _`AI12-0337-1`: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0337-1.txt