comp.lang.ada
 help / color / mirror / Atom feed
From: "jimmaureenrogers@worldnet.att.net" <jimmaureenrogers@worldnet.att.net>
Subject: Re: Ada exception block does NOT work?
Date: 18 Aug 2005 17:57:47 -0700
Date: 2005-08-18T17:57:47-07:00	[thread overview]
Message-ID: <1124413067.744497.224850@z14g2000cwz.googlegroups.com> (raw)
In-Reply-To: 1124390687.309704.156800@g44g2000cwa.googlegroups.com


Hyman Rosen wrote:
> jimmaureenrogers@worldnet.att.net wrote:
> > Please describe how you believe that Ada types are dynamic.
>
> Ada types incorporate values that depend upon runtime values.
> Array size is probably the simplest example - you can declare
> an array inside a procedure whose size is determined by a
> parameter to that procedure. I don't know Ada, but I'm pretty
> sure that you can also have types whose discriminants are set
> using values determined at runtime. As such, Ada types require
> local storage (in principle) for their representation, and it
> makes sense to free that storage once the scope in which the
> type is declared is exited. C++ types never depend on runtime
> values - they are always fully determined at compile time.

Ada types are also fully determined at compile time.
An unconstrained array type may have instances of different
lengths, but the type does not change. Likewise, a discriminant
type can have separate instances with different structures, but the
type is fixed at compile time.

C++ does not allow the definition of an array type in the sense
that it is defined in Ada. The typedef reserved word does not
create or designate a unique type. It only provides an alias or
alternate name for a type.

Ada types do not require any storage. Instances of types require
storage. In C++ a class with no static members requires no storage.
Each instance of that class requires its own separate storage. C++
variables may have scoping rules. Ada variables have scoping rules.
The rules are somewhat different, but the concepts are similar.

In C++ you can use a pointer to pass an array instance by reference.
The size of the array passed is determined at run-time. Ada allows
the definition of an unconstrained array type. Such a type can be
used as the parameter for a procedure or function. Each instance
of an unconstrained type must be constrained. The size of the
instance passed to an function or procedure may be determined at
run-time.

Ada also allows the definition of constrained array types. All
instances on a constrained array type have the same number of elements.
The size of all such instances is determined at compile time.

Except for classes, the C++ type system is relatively weak, and
is very similar to the C type system. Both C, and C++ provide a
wealth of implicit conversions between primitive types. This
makes the type system to appear much more dynamic than the Ada
type system. Ada provides no implicit conversions between types.
Ada's type system is both very strong and static.

You can declare local Ada types in internal blocks, according to
the values of variables:

procedure New_Type(Min, Max : Integer) is
   type Local_Type is range Min..Max;
begin
   for I in Local_Type'range loop
      Put_Line(Local_type'Image(I));
   end loop;
end New_Type;

Each time the procedure New_Type is executed Local_Type is
redefined. Local_Type has a scope only within the procedure
New_Type. If Min is greater than Max Local_Type will have a
null value range. This is not a case of a dynamic type.
It is an example of Ada elaboration. The declarative part of
the procedure New_Type is elaborated each time the procedure
is called, before execution of the body of the procedure
occurs.

Quoting from the Ada Language Reference Manual section 3.2.1:

The elaboration of a full_type_declaration consists of the elaboration
of the full type definition. Each elaboration of a full type definition
creates a distinct type and its first subtype.

This means that the type does not mutate from one call of the
procedure to another. Separate, distinct types are declared with
a lifetime controlled by the scope of their definition.

Jim Rogers




  parent reply	other threads:[~2005-08-19  0:57 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-16  8:48 Ada exception block does NOT work? bubble
2005-08-16  9:00 ` Georg Bauhaus
2005-08-16  9:32   ` bubble
2005-08-16  9:42     ` gautier_niouzes
2005-08-16 15:25       ` Frank J. Lhota
2005-08-16 16:58         ` Svesse
2005-08-16 17:48           ` Björn Persson
2005-08-16 18:12             ` Svesse
2005-08-16 18:17           ` Frank J. Lhota
2005-08-17 10:53         ` Ludovic Brenta
2005-08-17 11:34           ` Anders Wirzenius
2005-08-17 18:08             ` Björn Persson
2005-08-17 19:05               ` Randy Brukardt
2005-08-18 15:58               ` Georg Bauhaus
2005-08-16 12:30     ` Georg Bauhaus
2005-08-16 17:39       ` Björn Persson
2005-08-16 19:43         ` Georg Bauhaus
2005-08-17  1:39     ` Jeffrey R. Carter
2005-08-17  7:22       ` Maciej Sobczak
2005-08-18  1:05         ` Jeffrey R. Carter
2005-08-18  8:44           ` Maciej Sobczak
2005-08-18 11:40             ` Jean-Pierre Rosen
2005-08-18 12:56               ` Maciej Sobczak
2005-08-18 14:42                 ` Jean-Pierre Rosen
2005-08-18 18:03                 ` Martin Krischik
2005-08-18 13:15               ` Alex R. Mosteo
2005-08-18 15:23                 ` Dmitry A. Kazakov
2005-08-18 18:00                 ` Martin Krischik
2005-08-18 16:13             ` Jeffrey Carter
2005-08-18 16:38               ` Hyman Rosen
2005-08-18 18:07                 ` jimmaureenrogers
2005-08-18 18:44                   ` Hyman Rosen
2005-08-18 20:52                     ` Frank J. Lhota
2005-08-19  0:57                     ` jimmaureenrogers [this message]
2005-08-19  7:52                       ` Dmitry A. Kazakov
2005-08-19 14:41                       ` Robert A Duff
2005-08-19 17:48                   ` Martin Krischik
2005-08-19 14:58                 ` Robert A Duff
2005-08-18 17:54             ` Martin Krischik
2005-08-18 20:56             ` Robert A Duff
2005-08-18 22:01               ` Hyman Rosen
2005-08-19  2:35               ` Jeffrey R. Carter
2005-08-20 15:28                 ` Robert A Duff
2005-08-20 20:24                   ` Jeffrey R. Carter
2005-08-20 21:34                     ` Robert A Duff
2005-08-20 22:47                       ` Frank J. Lhota
2005-08-20 23:34                         ` Robert A Duff
2005-08-21 11:18                           ` Simon Wright
2005-08-21 16:59                             ` tmoran
2005-08-21 19:48                               ` Simon Wright
2005-08-21 16:07                           ` Frank J. Lhota
2005-08-21 16:23                           ` Martin Krischik
2005-08-21  1:12                       ` Björn Persson
2005-08-21  9:01                       ` Dmitry A. Kazakov
2005-08-21 16:14                       ` Martin Krischik
2005-08-21  4:02                     ` Larry Kilgallen
2005-08-19 12:34               ` Dr. Adrian Wrigley
2005-08-19 17:29                 ` Martin Krischik
2005-08-19 18:14                   ` Frank J. Lhota
2005-08-21 16:02                     ` Martin Krischik
2005-08-21 16:48                       ` Frank J. Lhota
2005-08-22 15:51                         ` Martin Krischik
2005-08-23  0:32                       ` Larry Elmore
     [not found]                         ` <h5dlg1tsie8n3ikirvbi508t9afobhctkj@4ax.com>
2005-08-23 18:09                           ` Martin Krischik
2005-08-23 19:50                             ` C history Björn Persson
2005-08-27 21:09                             ` Ada exception block does NOT work? Dave Thompson
2005-08-24  1:07                           ` Larry Elmore
2005-08-24  2:36                             ` Jeffrey R. Carter
2005-08-25  0:14                               ` Larry Elmore
2005-08-26  2:44                                 ` Jeffrey R. Carter
2005-08-24 16:44                             ` Martin Krischik
2005-08-22  8:12                     ` Hyman Rosen
2005-08-18 21:15             ` Robert A Duff
2005-08-19 12:00               ` Dmitry A. Kazakov
2005-08-17 20:24 ` Simon Wright
2005-08-18 19:36   ` Björn Persson
2005-08-18 21:07     ` Simon Wright
2005-08-22 10:47 ` bubble
replies disabled

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