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-Attributes: gid103376,gid1094ba,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!35g2000cwc.googlegroups.com!not-for-mail From: "jimmaureenrogers@worldnet.att.net" Newsgroups: comp.lang.ada,comp.lang.fortran Subject: Re: Ada vs Fortran for scientific applications Date: 9 Jul 2006 20:08:23 -0700 Organization: http://groups.google.com Message-ID: <1152500903.213295.241520@35g2000cwc.googlegroups.com> 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> <44B1763F.4050807@cits1.stanford.edu> NNTP-Posting-Host: 69.170.65.169 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1152500908 29703 127.0.0.1 (10 Jul 2006 03:08:28 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 10 Jul 2006 03:08:28 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: 35g2000cwc.googlegroups.com; posting-host=69.170.65.169; posting-account=SqOfxAwAAAAkL81YAPGH1JdBwpUXw9ZG Xref: g2news2.google.com comp.lang.ada:5589 comp.lang.fortran:11870 Date: 2006-07-09T20:08:23-07:00 List-Id: Brooks Moses wrote: > As a curiousity question, how would this work for cases such as, say, a > finite-volume grid where I have one range for the cells, and another > range for the faces between the cells, and want to do soemthing like this: > > type ncells is range 1..100; > type nfaces is range 0..100; > > cell : ncells; > leftface : nfaces; > rightface : nfaces; > > leftface = cell - 1; > rightface = cell; > > According your explanation those last two commands, while making logical > sense, would throw a type-mismatch error. How easy is that to "fix"? Ada makes a distinction between types and subtypes. The Ada definition of a subtype is a new alias for a type, with a possible subset of the range of valid values. Your example could be performed with a little subtype manipulation: type nfaces is range 0..100; subtype ncells is nfaces range 1..100; cell : ncells; leftface : nfaces; rightface : nfaces; leftface := cell - 1; rightface := cell; This works in Ada because all instance of a subtype are also instances of their base type. Nonetheless, any instance of ncells is limited to the range of value specified for the subtype. Assignment of 0 to an instance of ncells results in an invalid object. The invalidity of the object becomes an error when the invalid object value is evaluated. Ada provides the 'Valid attribute, which returns a boolean value, to indicate whether or not an object is valid. Evaluating the 'Valid attribute does not constitute an evaluation of the object, and therefore does not raise the exception Constraint_Error. Jim Rogers