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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c9d5fc258548b22a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!q2g2000pre.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Thu, 10 Feb 2011 09:05:26 -0800 (PST) Organization: http://groups.google.com Message-ID: 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> NNTP-Posting-Host: 174.28.151.164 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1297357526 14976 127.0.0.1 (10 Feb 2011 17:05:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 10 Feb 2011 17:05:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q2g2000pre.googlegroups.com; posting-host=174.28.151.164; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:17221 Date: 2011-02-10T09:05:26-08:00 List-Id: On Feb 10, 8:38=A0am, Hyman Rosen wrote: > On 2/9/2011 7:35 PM, Shark8 wrote: > > >> The problem with my SumTo subprogram is that it's liable to > >> raise Storage_Error for a wide range of legal arguments. > > > But are they your intended arguments? > > As MANY here have pointed out having (int x) is NOT > > a guarantee that X is not zero, nor is it guarantee it is not > > negative. > > And yet many C programmers ASSUME that they *ARE* whether > > based on comments or just assumptions is irrelevant to that point. > > You're not paying attention. You are falling into the language > wars trap of finding a perceived problem in C that is fixed by > Ada, and then no matter what I say, you say "but in Ada I can > guarantee that the input is not zero". My SumTo subprogram can > raise Storage_Error for a wide range of its legal arguments. > There is nothing in an Ada spec that declares how much call > stack is needed by a subprogram. 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. 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. > > >> The problem with my Exponent subprogram is that its running time > >> is enormous. > > > So, you didn't indicate that time was an issue. > > I kept asking you if I could replace your code with mine. > Computer programs are not abstract objects. They are run > in order to perform tasks. If you replace part of it with > something that is much slower, it's likely to be very bad. So, again you did *NOT* put in the requirement anything about running -time. This whole portion is somewhat akin to you complaining that your peg-leg prosthetic you got from the doctor makes it impossible for you to run when your request was "can you make it so I can walk around" and not something like "I want to run in a marathon." Furthermore, there are legitimate reasons why you might need a slower routine, namely to validate/check the 'speedy' algorithm. It would be absolutely *STUPID* to have a "sort" algorithm like: Type Integer_Array is (Positive Range <>) Of Integer; Function Sort( Input : Integer_Array ) Return Integer_Array is begin return Result : Integer_Array( Input'Range ):=3D ( Others =3D> 0 ); end sort; and then claim that because it's fast it is correct; though EVERY array it returns *IS*, in fact, sorted. > Again, you focus on what Ada can do (specify argument ranges) > and ignore as irrelevant what it cannot (time bounds). First, for all of your examples time *WAS* irrelevant; there was *NO* mention of any sort of requirement on time UNTIL you decided started objecting my conclusions. It's somewhat similar to saying that the method of breaking polygons into triangles to find the area is completely useless because it doesn't consider circles... even though we were discussing polygons themselves. Also, if that really IS the case then why then would you use C or C++ where you cannot do either. 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, except as a sort of TERMINATE IF DURATION LONGER THAN X. You could fairly easily make an run-time analyzer in LISP, since it is both recursive and homoiconic: so why aren't you using LISP?