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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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-20 04:13:59 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!dialin-145-254-039-241.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Proposed change to BC iterator parameters Date: Sat, 20 Dec 2003 13:20:13 +0100 Organization: At home Message-ID: References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-039-241.arcor-ip.net (145.254.39.241) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de 1071922437 9141573 145.254.39.241 ([77047]) User-Agent: KNode/0.7.2 Xref: archiver1.google.com comp.lang.ada:3623 Date: 2003-12-20T13:20:13+01:00 List-Id: Robert A Duff wrote: > "Dmitry A. Kazakov" writes: > >> But Robert wants it in a non-OO way! I think that he's right. The >> language should support both procedural and OO approaches, for they are >> complimentary. > > I'm not sure why you call the cursor style "OO". Cursor is an object! (:-)) > But yes, both styles > are useful. > > What I *really* want is that the iterator can be written in whichever > style is appropriate, and easily *used* in either style. Converting the > downward closure style to what you call the OO style (which I call the > cursor style) requires language support for coroutines, or something > very much like coroutines. Mmm, I am not sure what you mean. Technically either you pass a callback subroutine (+ its context) or you do an object (having a dispatching subroutine), both should be equivalent. The only difference is in syntactic sugar, i.e. (for cursor/OO approach) how easily one can derive a new type, override a subprogram, pack the necessary context stuff in a cursor instance. There should be a lot of sugar (and you have to do it at the library level, oops!) However, if we could put a subprogram body in an expression for the closure style, then we could also do it with the body of a cursor's override. Why not? So in both cases one could jump out of an iteration/recursion loop. But my concern is that non-local gotos and ad-hoc exceptions violate contract. Actually there is no any contract of an anonymous body. It is fine when the program is 50 lines long, but in a medium-sized project it might become a nightmare. What would your debugger show in the call-stack window for an anonymous body, after all? (:-)) > You can simulate coroutines using tasks and protected objects, but the > syntax is over-the-top heavy. Not to mention the inefficiency. -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de