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-Thread: 103376,29d8139471e3f53e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!83.128.0.11.MISMATCH!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!newsfeed.straub-nv.de!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Preventing type extensions Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <87iq2bfenl.fsf@mid.deneb.enyo.de> <874odv9npv.fsf@ludovic-brenta.org> <87y6b7cedd.fsf@mid.deneb.enyo.de> <66a3704c-54f9-4f04-8860-aa12f516134b@t3g2000vbb.googlegroups.com> <87d3sib44t.fsf@mid.deneb.enyo.de> <134q4k2ly2pf4$.17nlv1q6q5ivo.dlg@40tude.net> <878w35fqaa.fsf@mid.deneb.enyo.de> <1qinn2jjeco14.1tvq2qzalwqbt$.dlg@40tude.net> <87aan9d0r4.fsf@mid.deneb.enyo.de> Date: Wed, 22 Sep 2010 22:34:03 +0200 Message-ID: <8b5443tafw7w.1dr1vkuo72qn2$.dlg@40tude.net> NNTP-Posting-Date: 22 Sep 2010 22:34:01 CEST NNTP-Posting-Host: a5b1e1db.newsspool4.arcor-online.net X-Trace: DXC=GQZ=:P@1KFJ2jYf>V4L0gL4IUK On Wed, 22 Sep 2010 21:41:35 +0200, Florian Weimer wrote: > * Dmitry A. Kazakov: > >>>> No, the actual problem here is re-dispatch. Just do not do that, it is >>>> always bad. >>> >>> How do you suggest to avoid redispatch? Make non-dispatching calls to >>> dispatching subprograms? >> >> Yes. >> >>> And how does this address the issue? >> >> Because nothing can get broken by overriding, all targets are resolved. > > Perhaps not directly, but you still have the problem that you make the > extension because you want a behavioral change, and that change may > break other things. No, the point is that it cannot break existing code, because it is statically resolved and frozen. In Ada freezing is accomplished automatically by default. Any implementation in is frozen. You can use the implementation inappropriately, but that is your problem as a user. When you call sine instead of cosine you do not break either, you do your code only. > (And unlike Objective Caml, Ada has downcasts, so > the fact that there are unblessed extensions is very visible even > without resorting to non-portable bit fiddling.) That is another issue. In my opinion Ada should abstract all operations of the type. E.g. member access, pointer types evaluation, attributes etc. Conversion to a derived interface is another candidate to become a primitive operation, which you as a provider of the derived type should be able to override in order to have a finer control over downcasting. >>> It makes it more likely that you cannot write a useful extension. >> >> Why? I can override anything I need. > > Yes, but you may have to copy source code from the parent type's > implementation because it won't pick up your new code automatically. I can reuse parent's operations by calling them explicitly. > Back in mid-90s, there was a thought that it should be possible to > subclass all (public) classes and override all (public) methods. This > design is still followed by the JDK. I think this is quite the wrong > way to do OO. Yes, I stick to the design rule: override once. >>> Wouldn't it be better not to hide this aspect in the implementation? >> >> This does not compute to me. Are you saying that if an operation gets >> broken upon extension you won't allow to override it? (And if it is not >> broken, why do you care?) > > I want to make an explicit statement, "I do not support extending this > type" because I do not want to have the additional maintenance burden > of this dependency (or the debugging necessary because other code > breaks because there is an unexpected extension). That is not your business as a provider of the type. You cannot foresee further uses of the type and there is no burden on your side anyway. You publish the interfaces and provide some implementation for, and then you leave. > I can write this in > a comment, but I think it's better to make such things explicit in the > interface. Nope, as I already wrote in a subthread, the contract is between someone who extends the type and someone who uses it. You are not involved. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de