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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Redispatching (was: Your wish list for Ada 202X) Date: Wed, 16 Apr 2014 11:30:26 +0200 Organization: A noiseless patient Spider Message-ID: References: <7f1c01c5-3563-4b94-9831-152dbbf2ecdc@googlegroups.com> <8bhozh836pyt$.1qctlysud0s2q$.dlg@40tude.net> <1cdsyxjzsfgzm.1synpaujysv21$.dlg@40tude.net> <1aa804jg9qq4o$.wdiq33yo621l.dlg@40tude.net> <1w6eh0aiksmdh$.1h16p7y0b8c6h.dlg@40tude.net> <17twpp4p8u7o$.1idvzaaio4f3t$.dlg@40tude.net> <1wjmcbk375lzk.6o7dpqcp3va3.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 16 Apr 2014 09:30:26 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="23dab0694e4174fdc880833ec67fa650"; logging-data="23457"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jBnFCq0kOMrf+krscN/36" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: Cancel-Lock: sha1:GYb+oA0O0jcx6s+1lySjB8t9M84= X-Enigmail-Version: 1.6 X-Original-Bytes: 4102 Xref: number.nntp.dca.giganews.com comp.lang.ada:185768 Date: 2014-04-16T11:30:26+02:00 List-Id: Le 16/04/2014 08:32, Niklas Holsti a écrit : > As I understand them, both Dmitry and Randy would consider the > class-wide form a better solution, but it works only if you never need > to override these class-wide operations for any descendant types. > > I am seldom sure about that (never needing to override, not even in the > future), so I prefer to have the operations as primitive rather than > class-wide, and consequently to use re-dispatch. Actually, it's a different use case. Not much discussed in the litterature, because only Ada has a clear distinction between methods (primitive operations) and class-wide operations. A method is for the case where each type has its own way (method!) of doing things: you don't paint a button like you paint a text. A class-wide operation is usually a combination of (dispatching) calls to methods, to build higher level services; it's for the case where you want to make sure that all objects use the same algorithm; for example, when you move a widget, you want to guarantee that it is erased from its current position and repainted somewhere else, and that nobody will redefine move to do something else! It also ensures that should the algorithm change, the change needs to be done in only one place. As far as redispatching is concerned: since a method is linked to a single class, there should be no redispatching. Feeling a need for redispatching in a method is often a symptom that a class-wide operation is a better fit. And yes, chosing between methods and class-wide ops is not trivial and requires some thoughts; once you have a clear separation between these, it makes development a lot easier. Redispatching is mostly advocated by users of other languages that do not have class-wide operations, and use methods for what should be class-wide. In that case, failing to redispatch leads to incorrect behaviour. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr