Why are Controlled types so, well, strange?
(Tucker Taft responds): We considered many approaches to user-defined finalization and user-defined assignment. Ada presents challenges that make it harder to define assignment than in other languages, because assignment is used implicitly in several operations (by-copy parameter passing, function return, aggregates, object initialization, initialized allocators, etc.), and because Ada has types whose set of components can be changed as a result of an assignment.
(Tucker Taft responds): We considered many approaches to user-defined finalization and user-defined assignment. Ada presents challenges that make it harder to define assignment than in other languages, because assignment is used implicitly in several operations (by-copy parameter passing, function return, aggregates, object initialization, initialized allocators, etc.), and because Ada has types whose set of components can be changed as a result of an assignment. For example: type T (D : Boolean := False) is record case D is when False => null; when True => H : In_Hands; end case; end record; X,Z : T; Y : T := (True, H => …); … X := Y; — “X.H” component coming into existence Y := Z; — “Y.H” component going out of existence With a type like the one above, there are components that can come and go as a result of assignment. The most obvious definition of assignment would be: procedure “:=” (Left : in out In_Hands; Right : in In_Hands); Unfortunately, this wouldn’t work for the “H”
We considered many approaches to user-defined finalization and user-defined assignment. Ada presents challenges that make it harder to define assignment than in other languages, because assignment is used implicitly in several operations (by-copy parameter passing, function return, aggregates, object initialization, initialized allocators, etc.), and because Ada has types whose set of components can be changed as a result of an assignment. For example: type T (D : Boolean := False) is record case D is when False => null; when True => H : In_Hands; end case; end record; X,Z : T; Y : T := (True, H => …); … X := Y; — “X.H” component coming into existence Y := Z; — “Y.H” component going out of existence With a type like the one above, there are components that can come and go as a result of assignment. The most obvious definition of assignment would be: procedure “:=” (Left : in out In_Hands; Right : in In_Hands); Unfortunately, this wouldn’t work for the “H” component, because there