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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7f2ce8bda9cae4ab X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!peernews3.colt.net!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: "Must instantiate controlled types at library level." Why? Date: Fri, 14 May 2004 20:49:52 +0200 Organization: AdaCL Message-ID: <1616198.O4tUV8TdF7@linux1.krischik.com> References: <13392802.3gDeTK7ybb@linux1.krischik.com> <2780491.NPbR8AFya6@linux1.krischik.com> <11924003.IfRfnULeIG@linux1.krischik.com> <1676457.GMYvKY1ieA@linux1.krischik.com> Reply-To: krischik@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1084560676 04 21772 Cn42GGRL5ow05ta 040514 18:51:16 X-Complaints-To: usenet-abuse@t-online.de X-ID: VI2bwQZZZesveD3dV7EdyQn1QqcpsKTTwee6lNa8KdsDQnDzxSljwE User-Agent: KNode/0.7.7 Xref: controlnews3.google.com comp.lang.ada:590 Date: 2004-05-14T20:49:52+02:00 List-Id: Xenos wrote > "Martin Krischik" wrote in message > news:1676457.GMYvKY1ieA@linux1.krischik.com... >> Freejack wrote: >> Simple Mantra: 'Class behaves like String. >> >> If you compare with C/C++: You always have to uses char* pointers since >> C/C++ has no equivalent for String. > Wrong. C++ has a string class in its standard library. Its a lot more > versitile than Ada's String type. We are comparing languages capabilities here not libraries. the C++ string class in not build into the language. >> In C an array is either definite "int X[10]" or you use pointer. "int >> X[]" is only another syntax for "char*" since there is no 'First and >> 'Last in C/C++. Ada however has indefinite types - so pointers arn't >> neede here. > Wrong. In certain situations, an array will "degrade" to a pointer to its > element type. As a function parameter int X[] will degrade to a constant > pointer to an integer, or int * const. It is NEVER eqvilent to char*. > You must be thinking of Classic C (before the standard) were a char* was > used at > the generic pointer type before void* was introduced. A generic pointer > will accept any type of (non-function) pointer, but is still not > equivilent to it. No, You are am mistaken. Try this: class X { f (int *const x); f (int x[]); } Practical value is what counts. > It is only during degradation that an array end is unknown to the > compiler. The array bounds become unknown. Well, you have proven my point. It is even worse: Sometimes "sizeof X" will be the size of the array sometimes it is just the size of an pointer. > C++ has the vector (et. al.) where .begin() and .end() are > equivalent to 'First and 'Last. Again: vector is library not language. >> Also you use pointers because C/C++ has no "out" or "in out". Ada however >> decides itself if call by value or call by reference is needed. So no >> pointers needed here as well. > Wrong. C++ has reference types are equivalent to "in out." Constant > reference types may be used for "in." References are just "*const" with automatic referencing / dereferencing. Syntactic sugar no new semantic. You can even do: Some_Class& X = *new Some_Class; delete &X; Does work. Did it hundreds of times. If you use reference as class members the compiler will stop creating copy constructors and warn you if you forget to assign data inside the constructor. > If you don't understand a language, you don't have any grounds to lambaste > it. Just for the record: I have 10 years+ experience in C/C++ programming. I know which bugs I have hunted. I know when the dam compiler turned my arrays into pointer when I did not want, did not need it. Thank you very much. And this is why I am here in this Ada group: I only program C/C++ when I get paid for it and not one line for my private needs. With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com