comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: "Must instantiate controlled types at library level." Why?
Date: Fri, 14 May 2004 20:49:52 +0200
Date: 2004-05-14T20:49:52+02:00	[thread overview]
Message-ID: <1616198.O4tUV8TdF7@linux1.krischik.com> (raw)
In-Reply-To: c82iqd$7bl5@cui1.lmms.lmco.com

Xenos wrote

> "Martin Krischik" <krischik@users.sourceforge.net> 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




  parent reply	other threads:[~2004-05-14 18:49 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-11 23:04 "Must instantiate controlled types at library level." Why? Peter C. Chapin
2004-05-12  1:03 ` Jeffrey Carter
2004-05-12 10:47   ` Peter C. Chapin
2004-05-12 11:25     ` Ludovic Brenta
2004-05-12 14:41       ` Martin Krischik
2004-05-13  2:20       ` Peter C. Chapin
2004-05-12 11:55     ` Martin Krischik
2004-05-13  2:59       ` Peter C. Chapin
2004-05-13  7:10         ` Martin Krischik
2004-05-13 10:36           ` Peter C. Chapin
2004-05-13 11:18             ` Martin Krischik
2004-05-13 22:27               ` Peter C. Chapin
2004-05-13 22:54               ` Freejack
2004-05-14  7:13                 ` Martin Krischik
2004-05-14 13:50                   ` Xenos
2004-05-14 17:27                     ` Georg Bauhaus
2004-05-14 17:58                       ` Xenos
2004-05-14 18:49                     ` Martin Krischik [this message]
2004-05-14 19:40                       ` Xenos
2004-05-14 22:47                         ` Ludovic Brenta
2004-05-15  8:34                           ` Martin Krischik
2004-05-16  2:55                           ` Hyman Rosen
2004-05-16 13:48                             ` Ludovic Brenta
2004-05-17  2:30                               ` Hyman Rosen
2004-05-17  5:39                                 ` Martin Dowie
2004-05-17  7:48                                   ` Ludovic Brenta
2004-05-17 15:01                                     ` Hyman Rosen
2004-05-17 16:31                                       ` Georg Bauhaus
2004-05-17 17:40                                         ` Hyman Rosen
2004-05-17 19:17                                           ` Georg Bauhaus
2004-05-17  6:24                                 ` Martin Krischik
2004-05-17 19:48                                   ` James Kanze
2004-05-18  6:27                                     ` Martin Krischik
2004-05-17 12:33                                 ` Dmitry A. Kazakov
2004-05-17 13:46                                   ` Martin Krischik
2004-05-17 15:03                                     ` Dmitry A. Kazakov
2004-05-17 16:02                                   ` Alexander E. Kopilovich
2004-05-18  7:48                                     ` Dmitry A. Kazakov
2004-05-19  1:20                                       ` Alexander E. Kopilovich
2004-05-19  9:59                                         ` Dmitry A. Kazakov
2004-05-19 12:38                                           ` Hyman Rosen
2004-05-19 13:28                                             ` Dmitry A. Kazakov
2004-05-19 13:09                                           ` Georg Bauhaus
2004-05-19 13:44                                             ` Hyman Rosen
2004-05-19 14:17                                               ` Dmitry A. Kazakov
2004-05-19 14:15                                             ` Dmitry A. Kazakov
2004-05-21 11:39                                               ` Georg Bauhaus
2004-05-21 20:33                                                 ` Dmitry A. Kazakov
     [not found]                                                   ` <c8mkor$rlq$1@a1-hrz.uni-duisburg.de>
2004-05-23  1:28                                                     ` Hyman Rosen
2004-05-23  8:55                                                     ` Dmitry A. Kazakov
2004-05-24 11:38                                                       ` Georg Bauhaus
2004-05-24 13:57                                                         ` Dmitry A. Kazakov
2004-05-24 14:40                                                           ` Georg Bauhaus
2004-05-25  8:32                                                             ` Dmitry A. Kazakov
2004-05-25 15:47                                                               ` Georg Bauhaus
     [not found]                                   ` <URJ8Eg0vzF@VB1162.spb.edu>
2004-05-17 16:50                                     ` Marius Amado Alves
2004-05-18  8:27                                       ` Dmitry A. Kazakov
2004-05-15 17:20                     ` Pascal Obry
2004-05-13 19:33             ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox