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: 103376,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!m16g2000prc.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 10:22:25 -0800 (PST) Organization: http://groups.google.com Message-ID: <117ac99a-72c5-48db-8be1-6119fa309106@m16g2000prc.googlegroups.com> References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <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> <4d5423b9$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 1297362145 16119 127.0.0.1 (10 Feb 2011 18:22:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 10 Feb 2011 18:22:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m16g2000prc.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:17227 Date: 2011-02-10T10:22:25-08:00 List-Id: On Feb 10, 10:40=A0am, Hyman Rosen wrote: > On 2/10/2011 12:05 PM, Shark8 wrote: > > > On Feb 10, 8:38 am, Hyman Rosen =A0wrote: > >> 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! That's what happens when you reject as invalid any sort of reasoning about the program, now isn't it? > > Let me try to explain again. Writers here said that they look > at every line of C code and see bugs. So because someone else says something you are holding it to my account? How in Chaos is *that* valid? > 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. And you are insisting that is the wrong behavior. I have asked you if continuing to run and producing invalid results is valid, is it? > > 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. *I* never said that C has bugs on every line; I *have* said that in my experience it tends to encourage sloppy programming, but that is wholly different. > 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. > And your logic is flawed: you say that because someone else claims to see on every line of C code that my examples of how *SOME* errors -- NOT ALL -- are wholly preventable are invalid? > > 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. Um, no. I *AM* saying that you FAILED TO PROVIDE THE REQUIREMENTS. > > > 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. Ah, so now you say "because I like it" is a valid preference consideration while at the same time rejecting *my* preference for a type-system which allows me to exclude as least some invalid values? > > In fact, off the top of my head I cannot think of any language > > =A0> 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. And did I *EVER* say that the type system was itself EITHER necessary OR sufficient for meeting requirements? IIRC, I merely stated that it can help you follow the requirements, just like a Syntax-checker can tell you if some text is valid in its syntax cannot be relied upon to guarantee completeness OR correctness of the program. > > The C++ standard has O(=B7) requirements for the running time of > its container operations and algorithms, by the way. Ah, I know that there are some time requirements for Ada, but I don't know what they are; nor, at the moment, do I care; *NONE* of my current projects are time-sensitive.