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: 103376,fa18fb47ddd229a7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-17 12:59:52 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!newspeer.monmouth.com!newsfeed.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Proposed change to BC iterator parameters Date: 17 Dec 2003 15:59:51 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: pip1-5.std.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1071694791 22651 192.74.137.185 (17 Dec 2003 20:59:51 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 17 Dec 2003 20:59:51 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:3516 Date: 2003-12-17T15:59:51-05:00 List-Id: Jeffrey Carter writes: > Robert A Duff wrote: > > > Jeffrey Carter writes: > > > >>I agree with Duff in general, but in the case of providing iteration > >>over a protected structure, one must use an access-to-subprogram > >> parameter. > > I don't understand. Why can't one use the usual generic-iterator idea > > in that case? Maybe I don't understand what you mean by "protected > > structure"... > > Maybe you could give an example? > > See, for example, the Queue_Bounded structure in AI-302-01, in which the > queue is a protected type (section A.X.6). Ah, now I get it. Thanks. You want to pass a procedure to a protected procedure. You can't make the protected procedure generic, which would be the normal thing to do in the non-protected case. So you have to pass an extra context parameter. That technique works, but it gets pretty ugly at the call site. (I'm not blaming you -- the language is forcing you into a corner!) Also, you lose compile-time type checking -- the caller passes in an object of a specific type derived from Context_Data, and the loop-body procedure must downcast that, causing a run-time check. I wonder if it might not be a good idea to add a generic wrapper for all that? Then you probably wouldn't want the nonprotected versions to use this same interface. I'm still pushing for downward closures to be added to the language, which would add at least a minimal amount of support for iterators, and greatly simplify this and other data-structure proposals. An unrelated question about that AI: Why not combine the protected and blocking versions? (I really should review this AI carefully sometime... It would be very nice to get a data structure library into some future version of the language.) - Bob