comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Redefining := (was: The "()" operator revisited.)
Date: Fri, 16 Jan 2004 15:37:27 -0600
Date: 2004-01-16T15:37:27-06:00	[thread overview]
Message-ID: <100gmej9varun91@corp.supernews.com> (raw)
In-Reply-To: ltHNb.11315$1e.3373@newsread2.news.pas.earthlink.net

"Jeffrey Carter" <spam@spam.com> wrote in message
news:ltHNb.11315$1e.3373@newsread2.news.pas.earthlink.net...
> Robert A Duff wrote:
>
> > It has to do with mutable record types (defaulted discrims).
> > That's unfortunate; if you want to redefine ":=" for a non-mutable
> > type, it's pretty annoying to be told you can't do that because
> > mutable types exist in the language.

Bob's comment is a bit misleading. The problem is that since mutable types
exist in the language, you can't redefine ":=" for any types. That occurs
because of composition issues. You want user-defined ":=" to compose, such
that a larger type containing a component of a type using user-defined ":="
uses the user-defined ":=". Now, consider:

     type Something ...
     procedure ":=" (Target : out Something; Source : in Something);

     type Mutable (B : Boolean := False) is record
          case B is
                  when True =>
                          S : Something;
                  when False =>
                          C : Character;
          end case;
    end record;

    A_True : Mutable(True);
    A_False : Mutable(False);

    Obj : Mutable;

    Obj := A_True; -- ??

How does the predefined ":=" for Mutable work? It needs to call the
user-defined ":=" for component S. But in this example, what do you pass for
the LHS? It doesn't have a component S!

In order to deal with this, you pretty much have to separate the
finalization and initialization steps. Which is where the current model
comes from.

An alternative would be to require the ":=" to be overridden for Mutable.
But how would the user write that operation? They'd have to have made
finalization and initialization operations visible for Something, or it
isn't possible. And it seems to eliminate much of the advantage of allowing
user-defined versions of these operations (which is automatic composition).
(And the requirement probably would be a generic contract model problem. But
that's the least of the problems here.)

As Bob says, there are things you can't do with Adjust that you'd like to.
(It was described as a 75% solution when it was introduced. But our choices
were 75% or nothing, given the DRs opposition to anything fancier.) It's
hard to imagine doing much better without a lot of incompatibility (you
couldn't add a ":=" to an existing type without possibly breaking many uses
of the type) and a lot of work.

                   Randy.






  reply	other threads:[~2004-01-16 21:37 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-12 17:53 The "()" operator revisited Frank J. Lhota
2004-01-12 18:38 ` Frank J. Lhota
2004-01-12 22:26 ` Robert A Duff
2004-01-13 16:29   ` Frank J. Lhota
2004-01-13  9:24 ` Dmitry A. Kazakov
2004-01-13 16:44   ` Frank J. Lhota
2004-01-13 17:13     ` Hyman Rosen
2004-01-13 22:27     ` Randy Brukardt
2004-01-14  2:30     ` Stephen Leake
2004-01-14  9:04     ` Dmitry A. Kazakov
2004-01-17  0:15       ` Kenneth Almquist
2004-01-17 21:15         ` Robert A Duff
2004-01-19 10:25         ` Dmitry A. Kazakov
2004-01-13 13:13 ` Marin David Condic
2004-01-13 17:38   ` Warren W. Gay VE3WWG
2004-01-13 19:09     ` Robert A Duff
2004-01-15 17:30       ` Warren W. Gay VE3WWG
2004-01-15 18:11         ` Robert A Duff
2004-01-15 19:36           ` tmoran
2004-01-15 20:35             ` Robert A Duff
2004-01-17  5:48               ` Robert I. Eachus
2004-01-16  1:52           ` Redefining := (was: The "()" operator revisited.) Jeffrey Carter
2004-01-16 21:37             ` Randy Brukardt [this message]
2004-01-19 11:33               ` Dmitry A. Kazakov
2004-01-16  3:11           ` The "()" operator revisited Mark A. Biggar
2004-01-16 13:28             ` Hyman Rosen
2004-01-16 16:19             ` Robert A Duff
2004-01-16 18:09             ` Warren W. Gay VE3WWG
2004-01-16 13:56           ` Frank J. Lhota
2004-01-16 16:14             ` Robert A Duff
2004-01-16 21:29               ` Frank J. Lhota
replies disabled

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