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,9fb8e2af320d5b3e X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sat, 30 Jun 2007 19:41:05 +0200 From: Georg Bauhaus Organization: # User-Agent: Thunderbird 1.5.0.12 (Macintosh/20070509) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Bus error References: <0367891DA5DA7E408D42A860FA002F44B0CC48@sma2901.cr.eurocopter.corp> <1l4yqvxoid4n1.1u8eo4oo8ml4m$.dlg@40tude.net> <4685280c$0$14869$9b4e6d93@newsspool4.arcor-online.net> <46865672$0$23136$9b4e6d93@newsspool1.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <468694e4$0$20290$9b4e6d93@newsspool3.arcor-online.net> NNTP-Posting-Date: 30 Jun 2007 19:37:40 CEST NNTP-Posting-Host: 48da7620.newsspool3.arcor-online.net X-Trace: DXC=eb`ePA[[0e0lIh70@\BH3Y2QLV^TbmHZX9A:ho7QcPOV3gMAOmdVN:J>T7aTmVKhDN: X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:16359 Date: 2007-06-30T19:37:40+02:00 List-Id: Robert A Duff wrote: > Georg Bauhaus writes: > >> Dmitry A. Kazakov wrote: >>> On Fri, 29 Jun 2007 17:44:22 +0200, Georg Bauhaus wrote: >>> >>>> Dmitry A. Kazakov wrote: >>>>> function Very_Positive return Integer is >>>>> begin >>>>> return -1; >>>>> end Very_Positive; >>>>> >>>>> Oops : Positive renames Very_Positive; -- This is OK! > >> Oops will at some point raise Constraint error;... > > Dmitry's complaint is the above will NOT raise C_E. I see, yes, it won't raise at that point. I didn't jump to conclusions about faulty language design because (1) Ada has new when needed and (b) using subtypes will, I guess, require some compromises, i.e. range checks at run time. So I will get a (possibly surprising) Constraint_Error when I write Some_String(Oops). Positive'image is just as "tolerant". >> ...how can a compiler >> be supposed to known that some Integer function will *always* >> return non-Positives? > > Indeed! Likewise, how is the _programmer_ supposed to know? A programmer may be using Positive when it is clear from the logic of a program that in a region of the program, function Very_Positive will indeed compute positive return values from its inputs (and thus be aptly named). Otherwise, yes, mentioning subtype Positive in the renaming declaration would not be the best choice. When in other circumstances, the function returns values not necessarily positive, I expect the renaming to mention a different subtype. But OK, this subtype name is just a hint of varying value for the reader. >> ...What makes you think that the programmer >> who has written the Oops doesn't know what he is >> doing using a subtype, not a new type? >> >> I think it is a program design fault, if a fault at all (or a flaw as >> Bub Duff notes). > > Yes, I agree with you and with my evil twin Bub ;-) I'm sorry! <:-| -- Georg Too many scripting language programs, log files, and no sunshine for too many days here http://www.boersenspiel.de