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,7ee10ec601726fbf X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-01 09:37:08 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feeder.qis.net!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: why not Date: Thu, 1 Nov 2001 12:40:22 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <3BC5D730.DA950CC7@boeing.com> <9q4pa7$1ad$1@nh.pace.co.uk> <3BC6ACC8.23EF21BC@free.fr> <3BC71F54.1FFE78FA@boeing.com> <1KGx7.26476$ev2.35117@www.newsranger.com> <3BC7AD82.2A0CCCD4@acm.org> <9qhiqr$af0$1@nh.pace.co.uk> <1nDC7.180$6S7.92255364@newssvr11.news.prodigy.com> <9rjsak$bp3$1@nh.pace.co.uk> <9rmhb9$o1b$1@nh.pace.co.uk> <3BDEF0FE.B55FED9E@san.rr.com> <9rmuqi$es$1@nh.pace.co.uk> <3BDF1F13.4B99361C@san.rr.com> <9rnbtv$5i4$1@nh.pace.co.uk> <3BDF8C59.5020108@mail.com> <9rp9bk$6m9$1@nh.pace.co.uk> <9rrtkt$bum$1@nh.pace.co.uk> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:15555 Date: 2001-11-01T12:40:22-05:00 List-Id: "Marin David Condic" wrote in message news:9rrtkt$bum$1@nh.pace.co.uk... > I agree. Sorting needs to be inside of the data structure - not done > externally. Not necessarily. Sorting can done by a separate sort algorithm that operates on items via iterators. Or it can be a generic child function (see below). > However, it isn't clear if the container should always be > sortable or not. "Containers" are never sortable. "Sequences" are, assuming the element type has a comparison operator. But see the example below. > For example, if it is implemented as a generic and the > parameter is private, you don't have the operations one would need on an > ordinal type to do the sorting. This is the conversion Mark L and I had on CLA a couple of days ago. If the sort operation is part of the container itself, then you just import the operator(s) you need as a child function: generic type Element_Type is private; --with function "=" (L, R : Element_Type) return Boolean is <>; --maybe --with function Is_Equal (L, R : Element_Type) return Boolean is "="; --maybe package Lists is type List_Type is limited private; ... no, there is no sort op here! end; generic with function "<" (L, R : Element_Type) return Boolean is <>; procedure Lists.Generic_Sort (List : in out List_Type); No, do NOT import comparison operators in the formal part of the list package. Import the necessary operators from a generic child function. > (Too bad Ada didn't provide generic > parameters of "Ordinal" and "Scalar" so you could presume the existence of > comparison or arithmetic operators. Hmmmmm.....) If you bring in "<" and "=" > as function parameters, you can then insert/sort in ascending/descending > order as required - but now you impose that requirement on all things that > might be stored in the container. What if the items being stored are not > ordinal? Or you have no need of sorting? No. If you want to sort the container, then you can instantiate the generic child function separately. > You probably need two flavors of list there - one that accepts a private > type with no ordinal operations and one that has ordinal operations. No. > Then > you need a flavor of unsorted lists that take limited types and have an > imported assignment operation. Support of the limited element types is deferred pending discovery of characteristics of container types that have nonlimited and definite elements. > Then you need them in static vs dynamic > colors. Don't know what you mean. > Then you need them in protected and unprotected genders. Then you > need them......... (No wonder they aren't already in the standard! :-) No. The library prescribes only unprotected ("sequential" ) forms. It's up to the developer to add concurrency semantics himself, using other primitives already in the language. Just like Text_IO. Just like Discrete_Random.