From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1888e8caa20a2f2d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Thu, 08 Dec 2005 20:32:21 -0600 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <8sKdnXNeIZMxIg3eRVn-ig@comcast.com> <3trncoj4t0va.19bs46zhm4xbe.dlg@40tude.net> <2Rklf.171$n1.114@newsread2.news.pas.earthlink.net> Subject: Re: Controlled types and exception safety Date: Thu, 8 Dec 2005 20:36:38 -0600 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4952.2800 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4952.2800 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-OLB4djTB3mlWESggcS+lZnl1Xnr0zw7co6+HfwFQloDL1ytzjj+vYQpUoDLhOnbV3nR07AOzFlZbxWA!TdWabxL5hU1Qd33pdc9r1xbyTLLMymrX1I3sTtVcSMPes0EQW4LYKANrty+oM85O4CczrTmckqFz X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:6784 Date: 2005-12-08T20:36:38-06:00 List-Id: "Jeffrey R. Carter" 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.