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-Thread: 101deb,15c6ed4b761968e6 X-Google-Attributes: gid103376,gid1094ba,gid101deb,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.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,comp.lang.pl1 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> <%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> Date: Mon, 10 Jul 2006 09:38:47 +0200 Message-ID: <1kzktalo9krea$.z8n9wev45xct$.dlg@40tude.net> NNTP-Posting-Date: 10 Jul 2006 09:38:51 MEST NNTP-Posting-Host: be2542ea.newsread4.arcor-online.net X-Trace: DXC=kT4E2a@5adeGnN95NbAh:a:ejgIfPPlddjW\KbG]kaMhLL]:kiR8f=o9W[AW6JAAAc[6LHn;2LCVn7enW;^6ZC`dIXm65S@:3>o X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:5590 comp.lang.fortran:11872 comp.lang.pl1:1965 Date: 2006-07-10T09:38:51+02:00 List-Id: On Sun, 09 Jul 2006 21:36:07 GMT, James Giles wrote: > All the stuff I elided is interesting. Many of the features are even > good things for languages to have. None of them were checks for > undefined variables. > > Given the Ada program fragment: > > COUNT, SUM : INTEGER; > > [... lots of code ...] > [... some paths through which assign to SUM ...] > [... and some don't ...] > > COUNT := SUM+1; -- is SUM defined here or not? > > In most Ada implementations, as for most other languages, all > the bit patterns in the representation of an INTEGER data type > are valid integer values. There is no bit pattern representing > NOI (Not An Integer) corresponding to the IEEE float idea of > a NAN. Determining whether a variable is defined or not is a > complex problem. It's made worse by the fact that the user can > make the error message go away (though not usually the problem) > by initializing the variable in the declaration. 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 But not-a-value is IMO not a good idea. Firstly, it is run-time, i.e. too late. Secondly, it does not work for all types. What is not-a-bit, not-an-array, not-a-user-defined-type? If types like Integer had user-definable constructors, one could easily achieve not-a-value functionality using subtypes. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de