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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f891f,24f3e624c148455d,start X-Google-Attributes: gidf891f,public X-Google-Thread: 103376,1d321b3a6b8bcab2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-23 16:54:53 PST Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!gw1.att.com!fnnews.fnal.gov!uwm.edu!cs.utexas.edu!swrinde!ihnp4.ucsd.edu!network.ucsd.edu!mbk From: mbk@inls1.ucsd.edu (Matt Kennel) Newsgroups: comp.lang.ada,comp.lang.misc Subject: Re: "Subtract C, add Ada" Date: 24 Jan 1995 00:54:53 GMT Organization: Institute For Nonlinear Science, UCSD Message-ID: <3g1j4t$g8a@network.ucsd.edu> References: <3fv6lb$f4u@oahu.cs.ucla.edu> NNTP-Posting-Host: lyapunov.ucsd.edu Followups-To: comp.lang.misc X-Newsreader: TIN [version 1.1 PL8] Xref: nntp.gmd.de comp.lang.ada:18241 comp.lang.misc:10484 Date: 1995-01-24T00:54:53+00:00 List-Id: Jay Martin (jmartin@oahu.cs.ucla.edu) wrote: : Heh, (C Idiom == Idiotm) : >Writing ``for (p = head; p; p = p->next) { /* process list */ }'' : Ptr := Head; : while (Ptr /= null) loop : ... : Ptr := Ptr.Next; : end loop; : (My Ada is rusty, I only program in C++ now) "Think Globally, Act Locally." All these silly questions come down to the fact that control structures are hardwired into the language, but not easily reprogrammable. Real iterations in real problems come in many forms. You need a user-progammable construction that goes straight to the problem. C++ types 'iterators' are a good first step, but I don't feel super comfortable with them. What I think is even better is Sather's "iters". Instead of arguing over silly little details of various Pascal or C control structures or whatever their trivial variations, we should desire something much better and powerful among all the inventions that have been occured over the last 20 years. In particular I know about Sather's iters, which are practical and convenient. Example: -------- list,list2:LIST{BLAH}; loop list_element := list.elt!; -- iterate through elements of "list". process(list_element); while!(list_element /= special_gonzo); -- break out if we hit mr gonzo. list_element2 := list2.elt!; -- parallel (not nested) iteration through second list process2(list_element,list_element2); end; "elt!" is a feature in LIST{BLAH} which returns successive elements of the list, and breaks out if it hits the end. This fragment does exactly what it looks like it does. And the user of the "list" does not need to know whether it returns elements by dint of following successive pointers, stepping through arrays, or black magic. It eliminates stupid "off-by-one" errors and needless special boundary cases. cheers Matt -- -Matt Kennel mbk@inls1.ucsd.edu -Institute for Nonlinear Science, University of California, San Diego -*** AD: Archive for nonlinear dynamics papers & programs: FTP to -*** lyapunov.ucsd.edu, username "anonymous".