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!news2.google.com!news4.google.com!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail From: Brooks Moses Newsgroups: comp.lang.ada,comp.lang.fortran Subject: Re: Ada vs Fortran for scientific applications Date: Tue, 23 May 2006 11:34:44 -0700 Organization: Stanford University Message-ID: <447355C4.30306@cits1.stanford.edu> References: <0ugu4e.4i7.ln@hunter.axlog.fr> NNTP-Posting-Host: dnab42a587.stanford.edu Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.Stanford.EDU 1148409289 18326 171.66.165.135 (23 May 2006 18:34:49 GMT) X-Complaints-To: news@news.stanford.edu User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en In-Reply-To: Xref: g2news2.google.com comp.lang.ada:4382 comp.lang.fortran:10145 Date: 2006-05-23T11:34:44-07:00 List-Id: Dmitry A. Kazakov wrote: > On Tue, 23 May 2006 17:09:03 GMT, Dick Hendrickson wrote: >>Fortran 2003 has polymorphic variables which might make it >>easier to write a complete set of units and operators. That >>probably would lose some compile time checking. > > That depends on which kind of polymorphism it is. Ada provides three forms > of: > > 1. generics (like C++ templates) and overloading > 2. tagged types (like C++ classes) > 3. discriminated types. [...] > Then there is a problem of constraint propagation. Developing a matrix > library you surely would like to have dimensioned vectors and matrices all > constrained in a "coherent" way rather than on per-element basis. I doubt > that either 1. or 2. would be able to do it in an easy way. For what it's worth, the OpenFOAM CFD program that I've been working with (written in C++) has dimensioned variables, with dimension checking. It's all run-time, though; they've only got one type of "dimensioned variable" (a class with the variable value and a length-seven array containing the exponents of the dimensions) and then assignments and arithmetic operators check to make sure the dimensions agree. What they've done for their array library is to define a dimensioned array by adding dimension information to an array of undimensioned scalars, rather than constructing it directly as an array of dimensioned individual numbers. In practice, it seems to work quite well, and I suspect the run-time checking is generally of negligible cost since it's happening only once per array operation. (Of course, in code where it does happen once per scalar operation, it's rather more expensive.) - Brooks -- The "bmoses-nospam" address is valid; no unmunging needed.