From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: How can I create an empty array of a generic type? Date: Sat, 13 Jul 2019 14:19:26 -0700 Organization: None to speak of Message-ID: References: <5f53e122-6b99-48ca-b6cc-4ae43c0a2221@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="494b121aa0c8f1d94b8aec7426cc7869"; logging-data="7742"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EfRm/DZApGUZVftTYuV8/" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:TD6JXwh0F0mUT5jDMWRkM4yvplw= sha1:nfJWWtuQ7Ssj0vDZCpITlXyanD8= Xref: reader01.eternal-september.org comp.lang.ada:56866 Date: 2019-07-13T14:19:26-07:00 List-Id: "J-P. Rosen" writes: > Le 13/07/2019 à 06:11, Keith Thompson a écrit: >> generic >> type Element_Type is private; >> type Key_Component_Type is private; >> with function "<" (Left, Right : Key_Component_Type) return Boolean is <>; >> with function "=" (Left, Right : Element_Type) return Boolean is <>; >> package Ternary_Trees is >> type Key_Type is array(Positive range <>) of Key_Component_Type; >> private >> Dummy: Key_Component_Type; >> Empty_Key : constant Key_Type(1..0) := (others => Dummy); >> end Ternary_Trees; >> >> The Dummy value is a bit ugly. > You can avoid it: > Empty_Key : constant Key_Type(1..0) := (others => <>); Yes, that's better than my suggestion. (That feature was introduced in Ada 2005.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */