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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,de7dd126d6737f3a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!j1g2000vbl.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Callback in Ada Date: Sat, 27 Nov 2010 14:05:07 -0800 (PST) Organization: http://groups.google.com Message-ID: <20070c79-c5a7-4119-8b02-aafea42dec70@j1g2000vbl.googlegroups.com> References: <8lc2d0Fb6jU1@mid.individual.net> <87bp5boylc.fsf@ludovic-brenta.org> NNTP-Posting-Host: 85.1.103.106 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1290895507 8768 127.0.0.1 (27 Nov 2010 22:05:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 27 Nov 2010 22:05:07 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j1g2000vbl.googlegroups.com; posting-host=85.1.103.106; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:15683 Date: 2010-11-27T14:05:07-08:00 List-Id: On 27 Lis, 11:22, Ludovic Brenta wrote: > There are alternatives to callbacks; for example I believe Claw and Qt > use overriding primitive operations instead of callbacks. YAMI4 uses this approach for delivering messages and various notifications. AWS uses this, too. You have left that at the end of the list as if it was the least capable option, but I think that callbacks implemented this way (in particular with interfaces) have several important advantages: 1. They can be stateful. Procedure callbacks can refer to enclosing state as well, but for example having an array of stateful callbacks is less obvious. Interfaces can do that. 2. They are composable. A single entity can implement many callbacks and this can be enforced at the level of type system, not by mere convention. 3. Last but certainly not least: they can be implemented directly as protected or task objects. I would not use them for the passive iterator idiom, but for any form of asynchronous delivery, they can be very powerful. -- Maciej Sobczak * http://www.inspirel.com