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,efc9f994d31d0d5e X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Limited initialization for non-limited types Date: Fri, 28 Mar 2008 01:56:02 -0500 Organization: Jacob's private Usenet server Message-ID: References: <05336885-5b45-4b2d-b27c-733c2002ca58@s13g2000prd.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1206687376 7876 69.95.181.76 (28 Mar 2008 06:56:16 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 28 Mar 2008 06:56:16 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 Xref: g2news1.google.com comp.lang.ada:20610 Date: 2008-03-28T01:56:02-05:00 List-Id: "Eric Hughes" wrote in message news:05336885-5b45-4b2d-b27c-733c2002ca58@s13g2000prd.googlegroups.com... ... > Reviewing: > 1) Declaration of a function suitable for non-assignment > initialization. > 2) New specification of controlled behavior with such initialization. > 3) Syntactic distinction between assignment and initialization. > > I wasn't looking for this when I started this thread, but isn't this > exactly what's needed to define a proper constructor function? Exactly, but I think the chances of that happening in Ada are pretty close to zero. We tried a number of such approaches during the development of the Amendment, and we were unable to come up with compelling advantages to a large pile of new syntax and semantics (other than avoiding a nasty incompatibility). We eventually decided to go with the incompatibility instead. Moreover, I was one of those that was not originally convinced that a function makes an adequate constructor. But I wasn't able to convince others, and eventually you have to compromise and move on. Anyway, the Ada model for non-limited types is to allow compilers to do extensive optimization of assignment (or not). Code that requires a particular sequence of calls is wrong (even though it might work). I still think that your entire approach is wrong. I'd probably either try something using a mixin generic, or more likely simply with a bit debugging code built into the base class. (An extension would also work in some cases.) ... > The third consequence is that record extensions would require multiple > block memory copies. That means more internal accounting and some > extra code size. It would be quite a bit worse than that on some compilers. Combined with build-in-place and extension aggregates, you probably wouldn't even be able to figure out where the components are. (One implementation already has a problem with this.) I also wonder what dragons luck in this idea. A lot of good ideas simply don't work in Ada, because they run afoul of problems with discriminant dependent components or privacy or the generic contract model or some combination. It would take quite a bit of thought to ensure that such problems don't lurk here. Randy.