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: a07f3367d7,fdd685ffa59d584d X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: What would be the Ada solution? Date: Fri, 04 Feb 2011 11:57:42 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <0aa67233-4210-483b-b35c-8e872f87cb8f@r21g2000yqd.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1296838663 4870 192.74.137.71 (4 Feb 2011 16:57:42 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 4 Feb 2011 16:57:42 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:1UkZIjKQC/yk415hkXCLRDdn5rs= Xref: g2news2.google.com comp.lang.ada:17841 Date: 2011-02-04T11:57:42-05:00 List-Id: KK6GM writes: > A colleague is working on some old code, written in C, that uses an > "out of range" integer value to indicate no valid value. Thus, a > default value (in this case 0x7FFFFFFF) means no value has been > entered. All code that uses any values should check for this no-value > and act accordingly, but of course not all the code actually does > that, and there are odd cases where the no-value value gets processed > as a valid value and then Bad Things Happen. > > I'm curious what the Ada approach to this issue would be, the issue > being to differentiate between valid and invalid values, and to catch > (compile time or run time) any manipulation of an invalid value as if > it were a valid value. I suggest you read these two "gems": http://www.adacore.com/2010/04/05/gem-82/ http://www.adacore.com/2010/04/05/gem-83/ - Bob