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,c4cb2c432feebd9d X-Google-Thread: 1094ba,c4cb2c432feebd9d X-Google-Thread: 101deb,15c6ed4b761968e6 X-Google-Attributes: gid103376,gid1094ba,gid101deb,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!69.28.186.75.MISMATCH!hwmnpeer01.lga!news.highwinds-media.com!hw-filter.lga!fe09.lga.POSTED!53ab2750!not-for-mail From: "John W. Kennedy" User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 Newsgroups: comp.lang.ada,comp.lang.fortran,comp.lang.pl1 Subject: Re: Ada vs Fortran for scientific applications References: <0ugu4e.4i7.ln@hunter.axlog.fr> <%P_cg.155733$eR6.26337@bgtnsc04-news.ops.worldnet.att.net> <6H9dg.10258$S7.9150@news-server.bigpond.net.au> <1hfv5wb.1x4ab1tbdzk7eN%nospam@see.signature> <2006052509454116807-gsande@worldnetattnet> <1kzktalo9krea$.z8n9wev45xct$.dlg@40tude.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <2Nwsg.210$Dp4.31@fe09.lga> Date: Mon, 10 Jul 2006 14:12:33 -0400 NNTP-Posting-Host: 68.193.246.216 X-Complaints-To: abuse@cv.net X-Trace: fe09.lga 1152555198 68.193.246.216 (Mon, 10 Jul 2006 11:13:18 MST) NNTP-Posting-Date: Mon, 10 Jul 2006 11:13:18 MST Organization: Optimum Online Xref: g2news2.google.com comp.lang.ada:5597 comp.lang.fortran:11901 comp.lang.pl1:1967 Date: 2006-07-10T14:12:33-04:00 List-Id: adaworks@sbcglobal.net wrote: > "Dmitry A. Kazakov" wrote in message > news:1kzktalo9krea$.z8n9wev45xct$.dlg@40tude.net... >> On Sun, 09 Jul 2006 21:36:07 GMT, James Giles wrote: >> >> Yes, unfortunately this is one case, where Ada's default is not safe. A >> better design would be to require explicit initialization for all variables >> of types with assignment. If the programmer wanted to leave something >> uninitialized, he should do it explicitly: >> >> Sum : Integer := 0; >> Count : Integer := <>; >> Bar : Integer; -- Error: no public default constructor visible >> > Actually, explicit initialization with valid values, as shown above, can > increase the likelihood of errors. Ada will detect, at run-time, a value > that does not conform to the given type definition. > > A better solution, is to use Ada's > > pragma Normalize_Scalars > > as defined in the Safety and Security Annex of the Ada Language > Reference Manual. > > Further, it is not wise to use the predefined type, Integer, in most > cases. Rather, one should define the type with ranges and > constraints that conform exactly to the problem being solved. > This latter approach is one of Ada's strengths. For example, > > type My number_1 is range -2**15 .. 2**15 -1; > for My_Number_1'Size use 16; > -- more representation clauses, where appropriate > > or even > > type My number_2 is range -473..473; > for My_Number_2'Size use 12; > for My_Number'Alignment use some-boundary-number > -- more representation clauses, where appropriate > > Since this is a multi-language discussion, I am interested in the method > some of the other languages might use to define My_Number_1 and > My_Number_2. In particular, since Fortran and PL/I advocates are > contributing to the discussion, how do these languages approach this > issue. I'm sure PL/I has a good way to do this. PL/I is too old (1964) to have the range trick, but it does at least strive for portability by specifications such as: Declare My_number_2 fixed binary(8,0); If the (SIZE) option is turned on, it will at least check that the range is between -511 and +511. For alignment, it only has the options ALIGNED and UNALIGNED, both of which are implementation-defined (though on typical present-day hardware ALIGNED means aligned to the double-word/word/half-word/byte boundary appropriate to the data and UNALIGNED means aligned to the nearest byte, except for BIT, where ALIGNED means aligned to the nearest byte and UNALIGNED means aligned to the nearest bit. -- John W. Kennedy "The blind rulers of Logres Nourished the land on a fallacy of rational virtue." -- Charles Williams. "Taliessin through Logres: Prelude"