comp.lang.ada
 help / color / mirror / Atom feed
From: Eric Hughes <eric.eh9@gmail.com>
Subject: Re: Limited initialization for non-limited types
Date: Fri, 28 Mar 2008 08:25:08 -0700 (PDT)
Date: 2008-03-28T08:25:08-07:00	[thread overview]
Message-ID: <8ce4085b-08c9-4f3b-9909-3a68b8832194@s8g2000prg.googlegroups.com> (raw)
In-Reply-To: fsi4qg$7m4$1@jacob-sparre.dk

On Mar 28, 12:56 am, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> 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.

I haven't been able to find a smoking-gun example that you can't work
around with existing syntax.  I'm keeping my eye out for one, though.
The best I know of now is that it's problematic to eliminate default-
value initialization at compile-time (easy to do at run-time).  This
is useful only for types where no default value is sensible (such as
not-null-access types) and it's only relevant within a private
implementation (by eliminating public visibility of components).  On
the other hand, it's a missing aid to an implementer--in the same
class of aid as "type Index is new Integer"--not strictly necessary,
but a felicity of the language.

As to the technical part of the idea, I'll propose "::=" as token for
the initialization operator.

As to the build-in-place requirement, it seems part of a larger idea
I've been mulling over, which is a more general representation
facility.  As an example, in an ideal world, I'd like to have the
Convention, Import, and Export pragmas become ordinary code.  The core
theory is in Tony Hoare's paper "Proof of Correctness of Data
Representations" (1972).  Its essence is a formal way of mapping
between two different representations with equivalent ultimate
effect.  The largest visible change to Ada (or to any other language)
would be to make identifiers both for representation languages (name
spaces) and for representation conventions (maps between them).  I
doubt this will happen any time soon, though, since it seems a solid
research project to develop the necessary pragmatic theory to apply
this to a real language.

> Code that requires a
> particular sequence of calls is wrong (even though it might work).

Well, I'm not looking for any particular sequence of calls, really.
My immediate application is to verify invariants in run-time by
trapping on particular events (right now it's those of Controlled).

> 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.

I looked at initialization first because it's more widely applicable
outside of my immediate need, for which I think type discriminants may
work.  A discriminant whose access_definition is a handle to ordinary
record seems to allow most everything I can think I need soon.


[re: private components]
> It would take quite a bit of thought to ensure that such
> problems don't lurk here.

Granted.

Eric



  reply	other threads:[~2008-03-28 15:25 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
2008-03-28 15:25       ` Eric Hughes [this message]
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