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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news.glorb.com!news-xxxfer.readnews.com!textspool1.readnews.com!news-out.readnews.com!postnews7.readnews.com!not-for-mail Date: Thu, 10 Feb 2011 12:40:41 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <720b7e8f-1ae2-4b3b-851e-12b08b3c99e0@r4g2000prm.googlegroups.com> <4d52dd97$0$18057$882e7ee2@usenet-news.net> <9a8f406d-05ca-4bf3-8487-918d4e0dd634@o18g2000prh.googlegroups.com> <4d52ee47$0$18057$882e7ee2@usenet-news.net> <4d5306a0$0$18057$882e7ee2@usenet-news.net> <76c123ab-7425-44d8-b26d-b2b41a9aa42b@o7g2000prn.googlegroups.com> <4d5310ab$0$18057$882e7ee2@usenet-news.net> <9bff52ca-6213-41da-8fa4-3a4cdd8086d3@y36g2000pra.googlegroups.com> <4d5315c8$0$18057$882e7ee2@usenet-news.net> <159dca70-2103-46d7-beb2-c7754d30fe36@k15g2000prk.googlegroups.com> <4d53222d$0$18057$882e7ee2@usenet-news.net> <4d540714$0$27423$882e7ee2@usenet-news.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4d5423b9$0$27423$882e7ee2@usenet-news.net> NNTP-Posting-Host: 020cbea0.usenet-news.net X-Trace: DXC=R@Tc=bD0hSDOfXe]405M3NQFZ3T]GPM]GmX0AG3X_jUO3Cb99N\mXADVjKk:Lk^BNAcR12TN^Bg7N9]hck9n8BlIoC X-Complaints-To: abuse@usenet-news.net Xref: g2news1.google.com comp.lang.ada:17225 Date: 2011-02-10T12:40:41-05:00 List-Id: On 2/10/2011 12:05 PM, Shark8 wrote: > On Feb 10, 8:38 am, Hyman Rosen wrote: >> Why do you believe that it is >> a severe problem in C that I cannot specify in the language that >> a parameter is positive, but it is not a severe problem in Ada >> that you cannot tell me for which values my program will work? > > Because that's highly dependent on your system: is "integer" a > 32-bit value, a 64-bit value, a 48-bit value, a 128-bit value; are > integers 2's complement, or 1's complement? In the abstract > logic of programming it doesn't matter; that is, it only matters in > a specific instance, and that instance usually imposes some > requirements -- like your running time example -- which are not, > strictly speaking, in the requirements of the algorithm itself. I don't understand how this "because" answers my question. > If it's really an issue you would calculate, or run SumTo to > find the value which it overflows and then constrain it via > subtype: SubType SumTo_Range is Integer > 0..Integer'Pred( OVERFLOW_INPUT_VALUE ); > > And then you're on your merry way. You are suggesting that I rewrite my program by testing to see where it crashes on one platform and then restricting inputs to try to prevent that crash? That's C-like in its beauty! Let me try to explain again. Writers here said that they look at every line of C code and see bugs. I am telling you that I look at every line of Ada and I see bugs - you cannot tell me that a simple subprogram call will work, because it may crash the program instead by raising Storage_Error. What I am trying to make you see is that C code does not have bugs on every line, just as Ada code does not have bugs on every line. You look at C and say "What if the pointer is null, or the index is out of range?" I tell you that it is no more justified to think that each time than it is for me to look at Ada code and say "What if this subprogram call raises Storage_Error?" It is true that some C code will contain pointer and index errors, just as some Ada code will raise Storage_Error. But it is a bad mistake to assume that this is true everywhere in the code. > So, again you did *NOT* put in the requirement anything about > running -time. Right. You are inordinately proud of Ada's ability to capture numeric ranges in its type system. I am trying to show you that you are using that in the typical language wars way to lord it over another language that doesn't have that, but you are failing to realize, or ignoring, that there is a great deal more to requirements than what can be captured by a type system. > Also, if that really IS the case then why then would you use > C or C++ where you cannot do either. Because they are both good and capable languages with attractive, idiomatic, and powerful ways of doing certain things, and I like them. And partly because I'm an old fogey who learned C in 1980. > In fact, off the top of my head I cannot think of any language > which actually allows you to specify the running-time of a procedure Well, that's the point, isn't it? That's why being able to express numeric range restrictions in the language is no panacea for writing programs that meet their requirements. The C++ standard has O(�) requirements for the running time of its container operations and algorithms, by the way.