comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Limited initialization for non-limited types
Date: Fri, 28 Mar 2008 01:56:02 -0500
Date: 2008-03-28T01:56:02-05:00	[thread overview]
Message-ID: <fsi4qg$7m4$1@jacob-sparre.dk> (raw)
In-Reply-To: 05336885-5b45-4b2d-b27c-733c2002ca58@s13g2000prd.googlegroups.com

"Eric Hughes" <eric.eh9@gmail.com> 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.





  reply	other threads:[~2008-03-28  6:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-26 13:26 Limited initialization for non-limited types Eric Hughes
2008-03-26 14:02 ` Robert A Duff
2008-03-27  0:07   ` Eric Hughes
2008-03-26 15:08 ` Dmitry A. Kazakov
2008-03-26 22:13 ` Randy Brukardt
2008-03-27  3:25   ` Eric Hughes
2008-03-28  6:56     ` Randy Brukardt [this message]
2008-03-28 15:25       ` Eric Hughes
2008-03-28 21:53         ` Randy Brukardt
2008-03-28 23:37           ` Eric Hughes
2008-04-02  3:00         ` Eric Hughes
2008-03-26 23:00 ` Lucretia
2008-03-28 11:23 ` Martin Krischik
2008-03-28 15:47   ` Eric Hughes
2008-04-02  4:06 ` Eric Hughes
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox