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-Thread: 103376,ee1a8b8db84c88f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail From: "jimmaureenrogers@worldnet.att.net" Newsgroups: comp.lang.ada Subject: Re: Ada exception block does NOT work? Date: 18 Aug 2005 17:57:47 -0700 Organization: http://groups.google.com Message-ID: <1124413067.744497.224850@z14g2000cwz.googlegroups.com> References: <4301ab29$0$6989$9b4e6d93@newsread2.arcor-online.net> <%s2Ne.2$5F1.1@dfw-service2.ext.ray.com> <1124383129.977718.320820@g44g2000cwa.googlegroups.com> <1124388461.739578.189030@g14g2000cwa.googlegroups.com> <1124390687.309704.156800@g44g2000cwa.googlegroups.com> NNTP-Posting-Host: 69.170.70.49 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1124413073 24282 127.0.0.1 (19 Aug 2005 00:57:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 19 Aug 2005 00:57:53 +0000 (UTC) User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: z14g2000cwz.googlegroups.com; posting-host=69.170.70.49; posting-account=SqOfxAwAAAAkL81YAPGH1JdBwpUXw9ZG Xref: g2news1.google.com comp.lang.ada:4179 Date: 2005-08-18T17:57:47-07:00 List-Id: 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