Re: Controlled types and exception safety



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.


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.

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. 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.


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.

--
Jeff Carter
"Why don't you bore a hole in yourself and let the sap run out?"
Horse Feathers
49
.



Relevant Pages

  • Ada 2005 box (<>) rules in default values
    ... I have a doubt with the box operator as newly introduced in Ada 2005 to allow in place initialization of limited types. ... This actually compiles in GNAT GAP/GPL, but there's a thing happening that I don't know if it's that it isn't still completely implemented in Gnat, or is the expected behavior. ...
    (comp.lang.ada)
  • Re: another way to shoot yourself in the foot?
    ... It seems that an in-place initialization might result in n ... finalizations and n+1 initializations of the same thing. ... Aren't tasks limited types by definitions? ... terminated -- this part is from Ada 83. ...
    (comp.lang.ada)
  • Re: Controlled types and exception safety
    ... how is this assignment performed if we're using the default ... mistake early on in the Ada 95 process). ... >> Maybe Ada 200Y limited types and Assign procedures would be adequate, ... what's the value of preventing aggregates of types ...
    (comp.lang.ada)
  • Re: ADA Popularity Discussion Request
    ... > First, yes, I am the author of Ada Distilled. ... People do look at issues in programming languages ... Somehow I've never understood the point of making limited types a ... it has extensive facilities to support static array-based programming. ...
    (comp.lang.ada)
  • Re: How come Ada isnt more popular?
    ... Returning limited types is a compromise that can be ... satisfying in most cases - that's why it's good that Ada 2005 provides ...
    (comp.lang.ada)