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,58bffef5eda29ec X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-18 12:42:13 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Clueless :) Date: 18 Mar 2003 12:42:12 -0800 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0303181242.1ddd372a@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 1048020133 22387 127.0.0.1 (18 Mar 2003 20:42:13 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 18 Mar 2003 20:42:13 GMT Xref: archiver1.google.com comp.lang.ada:35480 Date: 2003-03-18T20:42:13+00:00 List-Id: Karel Miklav wrote in message news:... > Learning Ada I'm playing with container libraries and there are some > things puzzling me. If I initialize a generic container with an abstract > data type, this container will copy the whole ADT through and forth on > every assignment and alike. Isn't this an overkill? What do you mean by "copy the whole ADT" during assignment. Types don't get copied --only objects do-- so your question doesn't make any sense as written. > As I understand he gets in an iterator to increase, but he throws it > away and creates another one. Is it so cheap or am I missunderstanding > something about Ada compilers or something? You're constructing a new iterator object from an existing iterator object. Sort of like the function: class iterator { public: iterator succ() const; //.. }; For example: iterator i; //... i = i.succ(); The reason it's written this way in Ada is because scalar types have a built-in function that already does that: I : Integer; --... I := Integer'Succ (I); John was just being consistent with the rest of the language. The Charles container library (modelled on the C++ STL) is implemented similarly: http://home.earthlink.net/~matthewjheaney/charles/ > And one more question about the concept supported by keywords bounded, > unbounded, dynamic, fixed-length etc. Like first I must admit I don't > get it; why is there a need for this in Ada, when in tens of other > languages I've seen there is not? Because you don't have "bounded" forms in C++; that is, an array declared on the stack whose size is dynamic, i.e. void op(int n) { char str[n]; //not std c++ //... You can do this in Ada, in C99, and in g++. For example: procedure Op (N : Natural) is S : String (1 .. N); begin --... You typically need a "bounded" form in order to declare a stack-based container, whose maximum number of items ("size") isn't know until run-time: procedure Op (Size : Natural) is V : List_Subtype (Size); --no dynamic allocation begin > And why there are bounded, unbounded > and dynamic versions of Booch components but no polymorphic? Can't you just instantiate the container using an access type that designates T'Class?