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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.karotte.org!news2.arglkargh.de!noris.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada vs Fortran for scientific applications Newsgroups: comp.lang.ada,comp.lang.fortran User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <0ugu4e.4i7.ln@hunter.axlog.fr> Date: Tue, 23 May 2006 20:21:04 +0200 Message-ID: NNTP-Posting-Date: 23 May 2006 20:20:53 MEST NNTP-Posting-Host: b826ffc8.newsread4.arcor-online.net X-Trace: DXC=^C0b:g9Bd6H?_CdR_9TKXA:ejgIfPPldDjW\KbG]kaMH]kI_X=5KeaFka?A`3G=`TG[6LHn;2LCVN[ On Tue, 23 May 2006 17:09:03 GMT, Dick Hendrickson wrote: > Jean-Pierre Rosen wrote: >> Is it possible in Fortran to define three *incompatible* types Length, >> Time, and Speed, and define a "/" operator between Length and Time that >> returns Speed? > Yes, it's possible. There was a long thread inb c.l.f a > year or two ago abou this. It's a bit of a pain in the butt > to cover all the cases. Is E = m*c**2 the same as E=m*c*c? Hmm, where is any problem? As I remember 2 is integer in Fortran. I hope it can distinguish signatures ** : R x I -> R and ** : R x R -> R. Or do you mean a geometrical explosion of variants? > 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. All three can be used for dimensioned values. The last one is IMO the most promising, because it supports constrained subtypes. It is similar to Positive being a constrained Integer. So, for example, Energy can be statically constrained Dimensioned. Now, when all constraints are statically known, the compiler can potentially remove all run-time checks, as well as any memory overhead required to keep the dimension at run-time. 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. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de