comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Extension of non-limited type needs limited component
Date: Mon, 18 Nov 2002 14:33:03 -0600
Date: 2002-11-18T14:33:03-06:00	[thread overview]
Message-ID: <utijjlg8nl5d89@corp.supernews.com> (raw)
In-Reply-To: dstanbro-58E61E.23254817112002@mec2.bigpond.net.au

Dale Stanbrough wrote in message ...
>In article <wccbs4q8oys.fsf@shell01.TheWorld.com>,
> Robert A Duff <bobduff@shell01.TheWorld.com> wrote:
>
>> By the way, have you read the AARM annotations that explain why we
>> didn't allow user-defined ":=" procedures?  We certainly wanted to,
>> but we couldn't figure out how to make it work, so we invented
Adjust,
>> which is not as powerful.  I'd be interested in hearing better ideas
>> (even though it's probably too late).
>
>It seemed to me that the main problem with with discriminants
>in the tagged types. Would it not have been simpler just to
>disallow them? Would this have allowed you to have a ":="
>procedure?


No, the main problem is components of controlled types used in untagged
variant records. We hardly could disallow discriminants on all records!
We can't disallow components of controlled types that are
discriminant-dependent, because that would be a generic contract
violation. (Tagged types match generic formal private types.)
Assume-the-worst here would be very incompatible.

So, to get a first-class ":=", you'd have to make seriously incompatible
changes to Ada 83. (Not to mention Ada 95.) That just doesn't work.

To show the problem in short, assume that 'Window' is a controlled type
with a user-defined ":=".

     type Prob (B : Boolean := True) is record
         case B is
              when True => W : Window;
              when False => null;
         end case;
    end record;

    Obj_False : Prob (False);
    Obj_True : Prob (True);
    Obj : Prob;

    Obj := Obj_False; -- Component W disappears in this assignment. (It
is Finalized only.)
    Obj := Obj_True; -- Component W appears in this assignment. (It is
Adjusted only.)

So, what are the parameters to a user-defined ":="??

The problem is even more fun when it happens in a discriminant-dependent
array.

One of the nice things (from an implementability perspective) about the
Adjust solution is that it composes nicely. User-defined ":=" does not
seem to have this property unless disappearing components are somehow
disallowed.

              Randy Brukardt.








  reply	other threads:[~2002-11-18 20:33 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-13 10:03 Extension of non-limited type needs limited component Mike
2002-11-13 12:06 ` Jean-Pierre Rosen
2002-11-14  9:26   ` Mike
2002-11-14 11:43     ` David C. Hoos, Sr.
2002-11-14 12:33     ` Jean-Pierre Rosen
2002-11-14 14:27       ` Dmitry A. Kazakov
2002-11-14 19:25         ` Randy Brukardt
2002-11-15 10:04           ` Dmitry A. Kazakov
2002-11-15 22:09             ` Robert A Duff
2002-11-16 12:39               ` Dmitry A. Kazakov
2002-11-16 16:15                 ` Robert A Duff
2002-11-17 11:14                   ` Dmitry A. Kazakov
2002-11-17 12:26               ` Dale Stanbrough
2002-11-18 20:33                 ` Randy Brukardt [this message]
2002-11-18 21:48               ` Eric
2002-11-19 14:38               ` Eric
2002-11-15 21:41           ` Robert A Duff
2002-11-16  3:54             ` Randy Brukardt
2002-11-15  0:30         ` Robert A Duff
2002-11-15 10:22           ` Dmitry A. Kazakov
2002-11-15 21:56             ` Robert A Duff
2002-11-16 12:39               ` Dmitry A. Kazakov
2002-11-14 23:39     ` Robert A Duff
2002-11-15 21:51       ` Mike
2002-11-13 14:28 ` Robert A Duff
2002-11-14  9:33   ` Mike
2002-11-14  9:35     ` Lutz Donnerhacke
2002-11-14 21:41     ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
2002-11-15 10:47 Grein, Christoph
2002-11-15 12:12 ` Dmitry A. Kazakov
2002-11-15 13:29   ` Jean-Pierre Rosen
2002-11-15 14:34     ` Dmitry A. Kazakov
2002-11-15 21:26     ` Robert A Duff
replies disabled

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