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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fa18fb47ddd229a7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-21 10:13:07 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 21 Dec 2003 12:13:05 -0600 Date: Sun, 21 Dec 2003 13:13:05 -0500 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Proposed change to BC iterator parameters References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.34.214.193 X-Trace: sv3-c9RZ92e3sS06+ru2NpgJ8bOncPvF0+jdUl0u/A/kv2Rq5m1b6GGwiIRhFG6AR6fmsxl29EDCYamYh40!+AeG2YKJjkhibVFOYLWdAiYK8oKuBzAwO0Kq+GeTuShrAe7EzvT/Tgc9hVbstA== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:3674 Date: 2003-12-21T13:13:05-05:00 List-Id: Simon Wright wrote: > "Robert I. Eachus" writes: > > >>Currently I often provide tools in my data structures packages to >>provide everything viewed as an array. > > > Brilliant! now why didn't I think of that! Because you don't think like I do? "The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man." -George Bernard Shaw Also: "Some men see things as they are and say why? I dream things that never were and say 'Why not?'" -George Bernard Shaw and "To achieve the impossible, one must think the absurd; to look where everyone else has looked, but to see what no one else has seen." -Anon? I've been told since I was about 3 or 4 years old that I was a genius. But I have never felt like I was smart. I just wasn't quite as stupid as most people. But in this case, and in many similar cases, what happened was I approached the problem as a language designer rather than as a language user. I knew what I wanted to say, and if the language wouldn't let me say it, I would have argued for a change in the language. But for years I tried to figure out why people thought iterators were so important. At first I thought they were needed in tasking situations where a definite loop was not the right solution. But then I realized that for most tasking situations what you want is to view things as a linked list--even if the actual data structure is say a priority queue: loop declare Temp: Foo_Element_Type := Next(Foo); begin Process(Temp); exception when others => ...; end; end loop; Is a very common data structure. But when you use the idiom, the AST can be a queue, a list, a bag, a stack, or a heap. All you need is a next operation that removes the appropriate object from the structure and returns it. (For some element types you don't need the declare portion of the block, and for others you don't need the handler part, but this is the full pattern.) So I started putting Next operations in my data structure packages as well, and I still have never found a need for all the overhead of an iterator. If anyone knows of a pattern that requires all the overhead of an iterator instead of the array snapshot or the Next function, I'd like to know about it. (Of course, you also need the standard operations for the data structure, but these two patterns seem to be independent of the actual data structure.) Incidently, I probably need to include this information in the discussion of functions returning limited types... -- Robert I. Eachus "The war on terror is a different kind of war, waged capture by capture, cell by cell, and victory by victory. Our security is assured by our perseverance and by our sure belief in the success of liberty." -- George W. Bush