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,dbcfe2b0a74da57e X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!62.111.101.3.MISMATCH!news.germany.com!news.belwue.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Inherited Methods and such 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: <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> Date: Tue, 25 Sep 2007 10:59:09 +0200 Message-ID: <19ie8rfpiitdx$.i2sz3r6uj66w.dlg@40tude.net> NNTP-Posting-Date: 25 Sep 2007 10:53:34 CEST NNTP-Posting-Host: a6fa80db.newsspool2.arcor-online.net X-Trace: DXC=mGAKg`AUj;R@@RW1FjIB5SA9EHlD;3YcR4Fo<]lROoRQ<`=YMgDjhgRO9WU??BR[n_[6LHn;2LCV^7enW;^6ZC`TIXm65S@:3>_H1Yd2Jl\e[] X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:2126 Date: 2007-09-25T10:53:34+02:00 List-Id: On Mon, 24 Sep 2007 20:59:53 -0500, Randy Brukardt wrote: > "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. It can be made divisible: For each type T we define a plain built-in record type T'Constraints such that it has all the constraints (discriminants, bounds, tags) of T. Prior allocation of T a user hook is called to return T'Constrants. It gets the parameters of the constructor. Then the memory is allocated. After that the implementation type of T is constructed (the constraints are set, the components are constructed). Then we proceed to the construction of T. Here the parent types are constructed first and finally a user hook equivalent to Initialize is called on T. For class-wide types there is an additional step where the class-wide user hook is called. > 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. Same as above. Moreover it would be probably possible to make the old LHS visible in the hook computing the constraints. >> 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). That was a mistake, but overriding is a wrong model for constructors anyway. Constructors are extended but overridden. Further I don't think that constructing functions can be called constructors. We don't need constructors, we need insertions in the compiler-generated ones. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de