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-Thread: 103376,dbcfe2b0a74da57e X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!news.cs.univ-paris8.fr!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Inherited Methods and such Date: Mon, 24 Sep 2007 20:59:53 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1190039166.449906.15070@g4g2000hsf.googlegroups.com> <1190041908.492024.263110@19g2000hsx.googlegroups.com> <1190060534.958182.51800@d55g2000hsg.googlegroups.com> <87tzptuhku.fsf@ludovic-brenta.org> <1190125656.071013.303640@22g2000hsm.googlegroups.com> <1ds7l1l7oeyrx.1cpsvrpkikour.dlg@40tude.net> <1190147965.676457.123000@d55g2000hsg.googlegroups.com> <1co37tau98gct.axsglmqh0xu9$.dlg@40tude.net> <1190213376.707449.146640@g4g2000hsf.googlegroups.com> <1fl2wnziigxfd.1fjbag2hh8sbc$.dlg@40tude.net> <1190239986.762473.204290@k79g2000hse.googlegroups.com> <1rw45b3rmvmcr$.1df4wst5oknbl$.dlg@40tude.net> <1190296353.624737.150940@y42g2000hsy.googlegroups.com> <11m13st1f92kf$.m8s6y8mc8ebk.dlg@40tude.net> <1190321119.206313.65290@57g2000hsv.googlegroups.com> <1190408526.100291.265040@50g2000hsm.googlegroups.com> <9ukf2wtqjs0q$.iuijmal4x56b$.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1190685420 13223 69.95.181.76 (25 Sep 2007 01:57:00 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 25 Sep 2007 01:57:00 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Xref: g2news2.google.com comp.lang.ada:2119 Date: 2007-09-24T20:59:53-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:9ukf2wtqjs0q$.iuijmal4x56b$.dlg@40tude.net... ... > > Right. Ada doesn't have *any* constructors. :-) > > Surely it has. The point is that in NO typed language a constructor can be > defined solely in the language terms. Constructors have to be generated > "per magic." But the language shall provide hooks for user-defined > insertions in the generated constructors at the points, where the type > contracts are satisfied. Isn't it obvious? > > Ada keeps on trying to use only magic. Returning limited types, new in Ada > 2005, is just another step in this direction. Ada has no choice. You agree that "magic" is needed to do the memory allocation, layout, etc. for the underlying object. (To say otherwise would be to require all objects to be fixed in size.) But that is not divisible from the initialization of the value in Ada (and the values of the components), because the memory allocation depends on the value of the discriminants, and even the components that exist depends on those values. One could require all objects to be constrained at birth, or to not have discriminant-dependent components, but such a language is not Ada (even if it would work just fine for O-O purposes). Those things are a legacy of Ada's Ada 83 roots. Note that this is very similar to the reasons that Ada cannot have "real" user-defined assignment; it's not possible to divide an assignment into components managed separately. I made the mistake of thinking as you did when we implemented discriminated records in Janus/Ada (a long, long time ago). It led to a never-ending series of bugs, and an equal amount of work replacing it with code that actually works (and does all of the steps of initialization at once). > This is IMO a road to nowhere. It's way better than no constructors at all, which is the only other option. > And also, it is inconsistent with Ada's own stance on types > matching by-name rather than by-structure. This I don't see at all. Since constructors are named (and I agree that Initialize is not a constructor in any sense, its more of an initial mutator) and are tied to the return types, they fit well into the Ada type model. The best constructors are dispatching, and those surely are one-to-one with the types that they construct (Ada 95 required those to be overridden for each new type; the Amendment changed that over my strong objections, but even so you surely are allowed to override them). Randy.