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,2cc84c0fee9046c0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g43g2000cwa.googlegroups.com!not-for-mail From: "jimmaureenrogers@worldnet.att.net" Newsgroups: comp.lang.ada Subject: Re: Various Language Architecture Questions Date: 24 Sep 2005 22:07:05 -0700 Organization: http://groups.google.com Message-ID: <1127624825.425796.61240@g43g2000cwa.googlegroups.com> References: <1127615832.540718.246970@g43g2000cwa.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 1127624831 31162 127.0.0.1 (25 Sep 2005 05:07:11 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 25 Sep 2005 05:07:11 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g43g2000cwa.googlegroups.com; posting-host=69.170.70.49; posting-account=SqOfxAwAAAAkL81YAPGH1JdBwpUXw9ZG Xref: g2news1.google.com comp.lang.ada:5125 Date: 2005-09-24T22:07:05-07:00 List-Id: frankgerlach@gmail.com wrote: > Hello, > I am contemplating to create a new language, which is supposed to be as > fast as C++, but as safe as Java. Why limit yourself to a language as safe as Java? > Maybe Ada is already fulfilling these requirements, so I have a few > questions: > Is is possible to safely allocate objects on the stack and then pass a > pointer to these objects to a procedure ? Within limits, yes. The objects on the stack must be within scope when passed. Ada has very strict scoping and lifetime rules. You might want to read the Ada Reference Manual covering these areas. http://www.adaic.com/standards/95lrm/html/RM-TTL.html > (The stack is very fast, but I cannot tolerate invalid references from > the heap or from "older" stack regions) > Are the common Ada runtimes performing range checks on Arrays, > including "casted" pointers ? Ada does not confuse arrays and pointers like C and C++. Ada does perform range checks on arrays as a general rule. There are some situations where the compiler can determine that an out-of-range value is not possible, and therefore eliminates the range check. The programmer is also free to disable range checking when desired. > (Typecasting is necessary for high-performance access, but I want to be > safely in bounds of the array all the time) Typecasting is not a way of life for Ada. It is somewhat unusual. Ada access types (similar to references in Java) cannot be cast from one type to another. Ada uses Unchecked_Conversion for that purpose. > Also, it should be forbidden (by compiler or runtime) to cast a type > that contains a pointer to a different type. Does Ada support this ? (I > must secure pointers in order to have only valid pointers in the > system. Invalid pointers introduce random errors or security problems > for a sandbox execution model) Again, read the Ada language reference manual. Pay particular attention to the Ada type model. You will find that Ada's concept of type is far different than the C/C++/Java concept of a type. Primitive types can be coerced from one to the other with limitations. You cannot coerce a real number type to or from an integer number type. You cannot coerce an enumeration type to or from an integer number type. You cannot coerce any compound type to another compound type or to a scalar type. Tagged types do allow you to operate with a limited view of an object within the same inheritance hierarchy, but there is no true coercion or casting. Jim Rogers