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,fed2e7871ca258cd X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-28 11:11:14 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!ppp-1-29.cvx5.telinco.NET!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: List Container Strawman 1.4 Date: Fri, 28 Dec 2001 19:12:25 -0000 Message-ID: References: <87lmfsn2jj.fsf@deneb.enyo.de> <3C2CA143.6030006@mail.com> NNTP-Posting-Host: ppp-1-29.cvx5.telinco.net (212.1.152.29) X-Trace: fu-berlin.de 1009566673 21944639 212.1.152.29 (16 [25716]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: archiver1.google.com comp.lang.ada:18364 Date: 2001-12-28T19:12:25+00:00 List-Id: "Hyman Rosen" wrote in message news:3C2CA143.6030006@mail.com... > Ted Dennison wrote: > > > Actually, I was thinking along the lines of an Containers.Lists.Fixed > > > package that works with arrays. > > I think this kind of thing is where C++'s iterators and algorithms > approach shows its superiority. Why should a List have any notion > of other data structures to which its elements can be copied? > > In the STL, creating or copying one structure from another can be > done just using the std::copy algorithm, a pair of iterators giving > the source range, and a target iterator which receives the copies. > If you want to copy to a fixed-size array, the target iterator can > simply be a pointer to the first element. If you are creating a more > complicated target (such as another list, or a vector), then it is > the iterator that holds the semantics of where the data goes, for > example std::inserter or std::back_inserter. Well, speaking for what my own library (which I'm calling Tenet) will provide, I am supplying a set of container-wide iterator types, which come with a Copy_All procedure. So if I have, say, a lookup and a list, I can copy from one to the other thus: package Widget_Lookups is new Tenet.Lookups.Unbounded(Widget); package Widget_Lists is new Tenet.Lists.Unbounded(Widget); M: Widget_Lookups.Lookup; L: Widget_Lists.List; package Widget_Iteration is Tenet.Iteration(Widget); package Widget_Lookup_Iteration is new Widget_Lookups.Iteration(Widget_Iteration); package Widget_List_Iteration is new Widget_Lists.Iteration(Widget_Iteration); R: Widget_Lookup_Iteration.Reader; W: Widget_List_Iteration.Writer; ... Open(R,M); Open(W,L); Copy_All(R,W); Close(W); Close(R); It is all very wordy. The C++ equivalent is no doubt more concise. But, of course, this is only a tiny example. Realler software would show (IMHO ;-) the expressiveness of this design. In a hurry; must go. -- Best wishes, Nick Roberts