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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,UTF8 X-Google-Thread: 103376,73f15dbe4ec16d06 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-05 11:59:43 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-037-116.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Adding "()" operator to Ada 200X Date: Thu, 05 Jun 2003 21:02:17 +0200 Organization: At home Message-ID: References: <4a4de33a.0306030823.cd30642@posting.google.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-037-116.arcor-ip.net (145.254.37.116) Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8Bit X-Trace: fu-berlin.de 1054839582 12506521 145.254.37.116 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:38726 Date: 2003-06-05T21:02:17+02:00 List-Id: Mário Amado Alves wrote: >> > function "()" ( Source : in Array_Like_Type; >> > Index : in Index_Type ) >> > return Component_Type; >> >> To go along with this, a way to define a slice of an >> Array_Like_Type would be nice. > > Great idea! > > function "()" > (Source : in Array_Like_Type; > From : in Index_Type; > To : in Index_Type) > return Array_Like_Type; > > Or "(..)". IMO one should first add a new set of types: "index" types. With some set of predefined operations. Then you define sets over index types. "range" is an example of such a set. More interesting would be "column", "row" for a multi-dimensional index. (Ada does not have slices of multi-dimensional arrays). Then a square subset (specifies submatrix). Then a diagonal set ... ad infinum. (:-)) Only when you have proper index types, you can start to play with operations like slices and enumeration (in for-statement). If you have true index types and objects, you will need only one ()! function "()" ( Source : in Array_Like_Type; Index : Index_Like_Type ) return ? The problem is that, what the function returns, depends on how the index argument is constrained. This brings back a very important point of dealing with type constraints in a more general way than Ada presently does. For instance to allow () described above, one should treat: type Element is ... type Vector is array (Index_1) of Element; type Matrix is array (Index_1, Index_2) of Element; as differenty constrained subtypes of the same type Matrix. Both discriminants and tags can be considered type constraints. Then there are two major problems: 1. There has to be a way to remove statically known constraints. 2. There has to be a way to evaluate constraints in an independent body (from the original procedure body). > Yes, Matthew, it's just syntax. So are the (already) redefineable > operators. But it's really useful, no? Compare e.g. > ... > +"Marius", > +"Matthew", > ... > to > ... > new String' ("Marius"), > new String' ("Matthew"), > ... > > Actually the fact that it's just syntax might facilitate getting it > approved :-) > > BTW, I think that if a standard containers library is included in 200X > then Ada.Strings.Unbounded and the like should be revised in terms of > it. It would drastically reduce the size of the specs. It would > suffice to say something like > > Unbounded_String is equivalent to the container type > of an instantiation of Ada.Containers.Arrays.Unbounded > with the type Character. Oh that's for sure. For example: type X is tagged something; is an equivalent to type X is something; pragma Embedded_Tag (X); --- type X is limited something; is an equivalent to type X is something; procedure ":=" (L : in out X; R : Y) is null; --- ... -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de