comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Unknown discriminants with nested records
Date: Mon, 20 Jun 2011 09:16:57 -0700 (PDT)
Date: 2011-06-20T09:16:57-07:00	[thread overview]
Message-ID: <9b0c48f3-c4d7-44dc-8a79-bb38b7803366@y13g2000prb.googlegroups.com> (raw)
In-Reply-To: op.vw9jeu14ule2fv@douda-yannick

On Jun 18, 1:33 am, Yannick Duchêne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
> Le Fri, 17 Jun 2011 16:50:52 +0200, Robert A Duff  
> <bobd...@shell01.theworld.com> a écrit:> Jeff Carter is correct about the original reason for the (<>) feature
> > -- to fix the generic contract model, which was broken in Ada 83.
>
> This also had the nice side effect to allow to define types forcing  
> entities initialization.

A side effect that cannot be relied on, as is evident from this
thread.  As I tried to say earlier, if the language needs a feature to
allow the user to define a type for which objects must be initialized,
we should add a feature specifically for that purpose.  Trying to be
clever and pressing some other language feature into double duty seems
to come back to bite us most of the time.

As Jeff said, the problem in Ada 83 arose because the actual for a
generic formal could be a type for which you weren't supposed to be
able to declare an object (including a variable, record component,
array element type, etc.).  The (<>) feature was added not only to
generic formal types but also to private types; I'm not sure whether
the feature was added to private types just because it was being added
to generic formal types and someone thought it would make sense to add
it there too, or whether there were other considerations.  Anyway, I'm
guessing that the intent was more to *prevent* objects of the type
from being declared, much as it was in the generic formal case,
although one could still declare objects of an access to that type,
and one could still declare parameters of that type.  The fact that
you could still declare a variable of that type if it had an initial
value apparently gave some people a bright idea that the feature could
be used to force initialization.  But I don't think that was the
original intent; and when you use a feature for something for which it
wasn't intended, you run the risk that it won't always work for you,
which is what the OP found.

                            -- Adam



  reply	other threads:[~2011-06-20 16:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16 23:53 Unknown discriminants with nested records Simon Belmont
2011-06-17  0:39 ` Adam Beneschan
2011-06-17  1:48   ` Simon Belmont
2011-06-17 14:50     ` Robert A Duff
2011-06-18  8:33       ` Yannick Duchêne (Hibou57)
2011-06-20 16:16         ` Adam Beneschan [this message]
2011-06-17  6:03   ` Jeffrey Carter
replies disabled

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