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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, XPRIO autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,73f15dbe4ec16d06,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-02 09:35:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator2-sterling!news-in.nuthinbutnews.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny02.gnilink.net.POSTED!53ab2750!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada Subject: Adding "()" operator to Ada 200X X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: Date: Mon, 02 Jun 2003 16:35:01 GMT NNTP-Posting-Host: 151.203.199.168 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny02.gnilink.net 1054571701 151.203.199.168 (Mon, 02 Jun 2003 12:35:01 EDT) NNTP-Posting-Date: Mon, 02 Jun 2003 12:35:01 EDT Xref: archiver1.google.com comp.lang.ada:38375 Date: 2003-06-02T16:35:01+00:00 List-Id: There appears to be wide agreement that Ada 200X should include some sort of standard container library like Charles and PragMark. This library will probably include generic packages for creating and operating with dynamic lists and maps. One can view these kinds of collections as generalized arrays, and as such, it would be nice to use array notation for accessing a member of one of these collections. In other words, one should be able to define the "()" operator for array-like types, as follows: function "()" ( Source : in Array_Like_Type; Index : in Index_Type ) return Component_Type; For example, if the object Roster is a list of objects of type Player_Type, it would be quite desirable to be able to access the second player in Roster as Roster(2) For that matter, we could use the "()" operator to improve some existing Ada packages. The Ada.Strings.Bounded and Ada.Strings.Unbounded packages define the types Bounded_String and Unbounded_String that are enhanced versions of the String type. If Item is of type Bounded_String / Unbounded_String, we now access the third character of Item using the expression Element( Item, 3 ) Again, why not use the same notation that we would use if Item were declared as Standard.String (assuming that Item'First = 1 ), i.e. Item(3) If Ada 200X had an "()" operator, we could add the following declaration to Ada.Strings.Unbounded function "()" (Source : in Unbounded_String; Index : in Positive) return Character renames Element; With this declaration, we could use either "Element( Item, 3 )" or "Item(3)" to get the third element of Item. Of course, an array component can also be assigned a value, as in Item(3) := 'A': For that reason, we may also want to add an "():=" operator that is used to update a component of an array-like object, e.g. procedure "():=" ( Source : in out Array_Like_Type; Index : in Index_Type; Value : in Component_Type ); Again, we could enhance packages such as Ada.Strings.Bounded and Ada.Strings.Unbounded by declaring a "():=" operator that could be used in place of the Replace_Element procedures. I cannot help but think that this would be of tremendous help with whatever standard container library is added to Ada 200X.