Hi, I have a few technical questions, mostly about dynamic dispatching and inheritance.
A call on a dispatching operaiton shall not have both dynamically tagged and statically tagged controlling operands". Reason: This restriction is intended to minimize confusion between whether the dynamically tagged operands are implicitly converted to, or tag checked against the specific type of the statically tagged operand(s).
What is this rule ? I would have supposed a runtime check would rather ascertain that the dynamic and static variables match, instead of ruling out the combination a priori.
The book includes a paragraph on controlling results, and how tag-indeterminate expression are determined by context. It makes sense that you need neighboring static operands to resolve this. But if this works already, why do people talk of banning controlling results ?
What is the purpose of this rule: only immutably limited types can have anonymous access discriminants designating a limited type
. But it does not apply to discriminants of a named access type.
package main is
type KK is limited null record;
type KKAccess is access KK;
type BB (J: access KK) is null record;
function create return BB is (J => new KK); -- No
type CC (J: KKAccess) is null record;
function create return CC is (J => new KK); -- Yes
end main2;
Am I right that in the following, it is impossible to use anything in Complex_Functions at all ? It feels wrong to have access to a package but not to the types it references !
with Ada.Numerics.Generic_Complex_Types;
with Ada.Numerics.Generic_Complex_Elementary_Functions;
use Ada.Numerics;
generic
type NewF is new Float;
with package Complex_Types is new Generic_Complex_Types (NewF);
with package Complex_Functions is new Generic_Complex_Elementary_Functions (<>);
package main2 is
A: Complex_Types.Complex := Compose_From_Cartesian (2.3,4.9);
B: Complex_Types.Complex := Sqrt (A);
-- not same type, can I access whatever type Complex_Functions has access to ?
end main2;
Why can’t abstract types have/inherit non-abstract functions, while they inherit procedures ? I get that you can’t return a value of an abstract type but you can’t instanciate it to use in a procedure call either. The compiler and runtime should know which types are abstract and which aren’t anyway, no?
package P2 is
type T1 is tagged record
A: Integer;
end record;
function Create return T1 is (A => 3);
type T2 is abstract new T1 with null record;
type T3 is new T2 with null record; -- Create's body not inherited
end P2;
I can’t make (non) overriding indicators work:
package P1 is
type T1 is tagged record
A: Integer;
end record;
procedure Works (K: in out T1) with Import;
type T2 is new T1 with null record;
not overriding procedure Works (K: in out T2);
end P1;
p1.ads:7:24: error: subprogram “Works” overrides inherited operation at line 6
Thanks.