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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,73f15dbe4ec16d06 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-02 16:42:34 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Adding "()" operator to Ada 200X Date: 2 Jun 2003 16:42:33 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0306021542.58714996@posting.google.com> References: NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1054597354 5774 127.0.0.1 (2 Jun 2003 23:42:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 2 Jun 2003 23:42:34 GMT Xref: archiver1.google.com comp.lang.ada:38411 Date: 2003-06-02T23:42:34+00:00 List-Id: "Frank J. Lhota" wrote in message news:... > 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. > [snip] > I cannot help but think that this would be of tremendous help with whatever > standard container library is added to Ada 200X. But all you've done is change the syntax. None of your suggestions allow you to do more than is already provided by the library. To get a constant view of an element object, then all you have to do is: procedure Op (I : Iterator_Type) is E : ET := Element (I); begin To get an element object reference, you have to use an intermediate access type. To query do this: procedure Op (I : Iterator_Type) is X : ET := To_Access (I).all; begin To modify do this: procedure Op (I : Iterator_Type) is begin To_Access (I).all := Y; If you prefer, you can rename the element object. procedure Op (I : Iterator_Type) is E : ET renames To_Access (I).all; begin X := E; --query E := Y; --modify end; Alternatively, if you don't want to mess around with access types, then you can use Replace_Element instead: Replace_Element (I, E); If this is a set or a map, you can always unconditionally modify an element using Insert: Insert (Set, E); --sort of like Set (Get_Key (E)) := E; Insert (Map, Key, E); --sort of like Map (Key) := E; If you're going to make a change in the syntax of the language, then it has be because it allows you to do something you can't do already. For example, there's no way to declare an access subtype right now that means "all the access values except null." A useful language change would be to allow the declaration: type Element_Access_Base is access all Element_Type; subtype Element_Access is Element_Access_Base range not null;