comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Controlled types and exception safety
Date: Thu, 8 Dec 2005 20:36:38 -0600
Date: 2005-12-08T20:36:38-06:00	[thread overview]
Message-ID: <dvidnUm4m8crcQXeRVn-gw@megapath.net> (raw)
In-Reply-To: xX%lf.800$n1.254@newsread2.news.pas.earthlink.net

"Jeffrey R. Carter" <spam@spam.com> wrote in message
news:xX%lf.800$n1.254@newsread2.news.pas.earthlink.net...
> Randy Brukardt wrote:
>
> > Now, how is this assignment performed if we're using the default
assignment
> > here? Since we need to component, we need to call the Assign procedure
on
> > the component C, but what left-hand side to pass as To? There isn't a
> > component O.C in the left-hand side!
>
> I guess I'm still missing something. Default assignment to a record with
> discriminants, or at least that changes the discriminants, invoking
'Assign for
> a component, would assign to an intermediate with the correct
discriminants,
> which is then copied into the target as is currently done.

You're expecting a bitwise copy to work for that? That seems wrong; since
the advantage to your scheme is that you can do operations on the old
left-hand side before the assignment. But if that "old" object is a
temporary, you have no access to it, and you have degraded to the current
scheme. Except that it is worse, because you can't have position-dependent
items.

What I mean by the latter is something that depends on the actual object,
such as 'Access of it. Claw depends on that heavily; Adjust and Finalize
updates or removes the pointers from the various internal lists. That
doesn't work if the LHS isn't the final one (at least one compiler made that
mistake early on in the Ada 95 process).

> Working out the rules is probably complicated, and hardly worth the effort
since
> Ada uses another mechanism, but I'm still not convinced it couldn't be
done.
>
> Probably because IANALL and I'm missing something.

Probably because what you're suggesting would be less useful than Adjust is,
if it had no guarateed access to the LHS *and* it didn't allow self-pointers
and the like.

> > Maybe Ada 200Y limited types and Assign procedures would be adequate,
but
> > certainly not the Ada 95 variety. Ada 95 limited types don't allow (1)
> > aggregates; (2) constants; (3) useful functions; or (4) any sort of
complex
> > initialization. Which means that you can't use many of the techniques
that
> > help reduce bugs in Ada (such as letting the compiler check that all
> > components have been given in an aggregate). And limited types also
block
> > most optimizations by their very nature. That's useful in some cases,
but in
> > others you'd rather let the compiler eliminate extra temporaries and
> > Finalizes. (That's allowed for non-limited types, but never for limited
> > types.)
>
> I've always felt that preventing the use of aggregates was an important
part of
> limited types.

That seems odd to me; what's the value of preventing aggregates of types
containing components of the limited type? (Preventing aggregates of limited
private types is a feature of private types, not limited types.)

> Constants don't seem like a problem, since they can be
> implemented as functions. You can pass function results to the From
parameter of
> Assign.

Not in Ada 95; you can't write a useful function without standing on your
head. Such a function can only return a global variable, which is ugly at
best and impossible for anything but literal constants.

> Complex default initialization requires some work, but I was able to do
some
> pretty complex default initialization using functions as default initial
values
> in Ada 83. Preventing user-defined initialization seems like an important
part
> of limited types.

Again, you seem to be confusing features that belong to other things
(private types and the <> discriminant) with limited types. You can prevent
user-defined initialization in other ways, so it's not necessary to make
that a feature of limited types.

The *only* thing limited types are about is preventing copying. Limited
objects are supposed to be always built-in place. That's important, because
in order to get that one feature (no copying), it's nasty to get a passel of
other things that you may or may not want. And if you don't want those other
things, you often have to abandon limited types. (The major reason that most
objects are non-limited in Claw is that limited functions aren't useful in
Ada 95.)

We've tried to eliminate unnecessary restrictions on the categories of
types, so that it is possible to pick categories based on their main
properties - with as few surprises as possible.

                              Randy.







  reply	other threads:[~2005-12-09  2:36 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-30 13:57 Controlled types and exception safety Maciej Sobczak
2005-11-30 15:06 ` Dmitry A. Kazakov
2005-11-30 16:19   ` Maciej Sobczak
2005-12-01  0:05     ` Stephen Leake
2005-12-01  9:21     ` Dmitry A. Kazakov
2005-12-01 10:46       ` Maciej Sobczak
2005-12-01 15:08         ` Dmitry A. Kazakov
2005-12-02  4:17           ` Randy Brukardt
2005-12-02  9:29             ` Maciej Sobczak
2005-12-02 18:12               ` tmoran
2005-12-02 19:15                 ` Robert A Duff
2005-12-02 21:42                   ` tmoran
2005-12-06  9:00                     ` Maciej Sobczak
2005-12-06  9:50                       ` Dmitry A. Kazakov
2005-12-06 18:34                         ` Jeffrey R. Carter
2005-12-06 19:34                           ` Randy Brukardt
2005-12-06 21:20                             ` Dmitry A. Kazakov
2005-12-07  1:57                             ` Jeffrey R. Carter
2005-12-08  0:50                               ` Randy Brukardt
2005-12-08 19:37                                 ` Jeffrey R. Carter
2005-12-09  2:36                                   ` Randy Brukardt [this message]
2005-12-09  6:33                                     ` Jeffrey R. Carter
2005-12-09 20:35                                       ` Randy Brukardt
2005-12-10  7:53                                         ` Jeffrey R. Carter
2005-12-06 20:43                           ` Dmitry A. Kazakov
2005-12-07  2:00                             ` Jeffrey R. Carter
2005-12-07 10:01                               ` Dmitry A. Kazakov
2005-12-02 23:21             ` Robert A Duff
2005-11-30 17:46 ` Jean-Pierre Rosen
2005-11-30 21:02 ` Jeffrey R. Carter
2005-11-30 22:06   ` Björn Persson
2005-11-30 23:52     ` Randy Brukardt
2005-12-01  5:26     ` Jeffrey R. Carter
2005-12-02 23:51       ` Robert A Duff
2005-12-06 11:41   ` Peter C. Chapin
2005-12-06 12:50     ` Jean-Pierre Rosen
2005-12-06 13:06     ` Dmitry A. Kazakov
replies disabled

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