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.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,582dff0b3f065a52 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,bc1361a952ec75ca X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-09 09:52:57 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada,comp.lang.c++ From: Ted Dennison References: <3B6555ED.9B0B0420@sneakemail.com> <87n15lxzzv.fsf@deneb.enyo.de> <3B672322.B5EA1B66@home.com> <5ee5b646.0108010949.5abab7fe@posting.google.com> <%CX97.14134$ar1.47393@www.newsranger.com> <9ka1jc$mgd@augusta.math.psu.edu> <3b690498.1111845720@news.worldonline.nl> <9kbu15$9bj@augusta.math.psu.edu> <9kbvsr$a02@augusta.math.psu.edu> <3B69DB35.4412459E@home.com> <9kp9n7$ivm$1@nh.pace.co.uk> <1exve0j.1lboe8gneysd0N%clarkcox3@yahoo.com> Subject: Re: How Ada could have prevented the Red Code distributed denial of service attack. Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Thu, 09 Aug 2001 12:52:44 EDT Organization: http://www.newsranger.com Date: Thu, 09 Aug 2001 16:52:44 GMT Xref: archiver1.google.com comp.lang.ada:11692 comp.lang.c++:81270 Date: 2001-08-09T16:52:44+00:00 List-Id: In article <1exve0j.1lboe8gneysd0N%clarkcox3@yahoo.com>, Clark S. Cox III says... > > What happens when you want to skip over an element of the vector? >delete an item from the vector? You do it some other way than modifying the loop control variable, or you use a different kind of loop structure where the lcv *can* be modified. The option is still there, its just that the standard "for" is something safer and easier to optimize. :-) > It can be, but it can also be an inline function, or a simple >call-through to the built in operator++, in both cases, any compiler Can it? In Ada at least, I understand that potentially dynamic-dispatching operations are really tough to inline. I suppose there could be something I don't know about C++ that gets rid of that issue. Is there? >worth it's salt would only use a single machine instruction (unless, of Well, that's easy to *say*. But if your compiler can't inline dispatching calls, and "++" is a dispatching call, then it won't get inlined, and you will have procedure call overhead for every increment. This isn't an issue at all for Ada "for" loops, because the incrementing is *implicit*. Well...to be truthful, you'd have the same issue with Ada if you used some abstract tagged private type in a "while" loop instead, which would be a direct translation of what you've done in C++. But in Ada you don't need to do that just to get type safety. The base types already have it (if you don't disable it). >>The Ada for loop is going to use whatever hardware incrementation >>method is fastest (assuming it doesn't just unroll some or all of the >>loop). In a tight loop, the speed difference could be significant. > > This is no different from what a decent C++ compiler would do. Quite true. The difference is that its much *easier* for an Ada compiler to do this, becuse far more of the nessecary information is available to the optimizer at compile time. For instance, its tough to fully unroll a loop, if you don't know until runtime how many iterations it is going to have. In your C example, there's no easy way the compiler could figure that out, as it is determined by whether you modify "i" anywhere else in the body of the loop (including potentially within called subprograms via an alias), and by the implementation of that library "++" routine (which you could have even overridden, for all it knows). None of this is an issue for an Ada compiler, because "i" *can't* be (legally) modified at all. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com