From: reinert <reinkor@gmail.com>
Subject: Re: How can I create an empty array of a generic type?
Date: Sun, 14 Jul 2019 04:09:59 -0700 (PDT)
Date: 2019-07-14T04:09:59-07:00 [thread overview]
Message-ID: <8a591def-8148-433e-bd19-e88b22f50284@googlegroups.com> (raw)
In-Reply-To: <lnblxxaazl.fsf@kst-u.example.com>
lørdag 13. juli 2019 23.19.28 UTC+2 skrev Keith Thompson følgende:
> "J-P. Rosen" <rosen@adalog.fr> 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 <http://www.ghoti.net/~kst>
> Will write code for food.
> void Void(void) { Void(); } /* The recursive call of the void */
But Key_Type is an array indexed by Positive (> 0).
The zero in "Key_Type(1..0)" is not so intuitive for me (outside the range) ?
reinert
next prev parent reply other threads:[~2019-07-14 11:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-13 3:36 How can I create an empty array of a generic type? b.mcguinness747
2019-07-13 4:11 ` Keith Thompson
2019-07-13 5:24 ` J-P. Rosen
2019-07-13 21:19 ` Keith Thompson
2019-07-14 11:09 ` reinert [this message]
2019-07-14 11:15 ` reinert
2019-07-14 11:27 ` Jeffrey R. Carter
2019-07-14 12:49 ` J-P. Rosen
2019-07-13 21:02 ` b.mcguinness747
2019-07-14 16:41 ` bj.mooremr
2019-10-16 2:03 ` Andrew Shvets
2019-10-16 4:49 ` Egil H H
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox