From be3083ae5e982d21363eb54ba287df2961c0f794 Mon Sep 17 00:00:00 2001 From: Leo Germond Date: Thu, 6 Mar 2025 14:46:09 +0100 Subject: [PATCH 1/4] polymorphism: reorder intro --- .../180_polymorphism/01-introduction.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/courses/fundamentals_of_ada/180_polymorphism/01-introduction.rst b/courses/fundamentals_of_ada/180_polymorphism/01-introduction.rst index 9faac8fc9..526e7c662 100644 --- a/courses/fundamentals_of_ada/180_polymorphism/01-introduction.rst +++ b/courses/fundamentals_of_ada/180_polymorphism/01-introduction.rst @@ -8,9 +8,6 @@ Introduction * :ada:`'Class` operator to categorize :dfn:`classes of types` * Type classes allow dispatching calls - - - Abstract types - - Abstract subprograms - -* Runtime call dispatch vs compile-time call dispatching +* :dfn:`Static dispatch` at compile-time (overloading) +* :dfn:`Dynamic dispatch` at run-time From 13ca573b9406c16c8d1de5a2a80a3192cd12baa0 Mon Sep 17 00:00:00 2001 From: Leo Germond Date: Thu, 6 Mar 2025 14:46:49 +0100 Subject: [PATCH 2/4] poly: use the :ada:`` role where it was missing --- .../180_polymorphism/02-classes_of_types.rst | 14 +++++++------- .../03-dispatching_and_redispatching.rst | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/courses/fundamentals_of_ada/180_polymorphism/02-classes_of_types.rst b/courses/fundamentals_of_ada/180_polymorphism/02-classes_of_types.rst index eacd08f2e..1cd8823a0 100644 --- a/courses/fundamentals_of_ada/180_polymorphism/02-classes_of_types.rst +++ b/courses/fundamentals_of_ada/180_polymorphism/02-classes_of_types.rst @@ -7,8 +7,8 @@ Classes ---------- * In Ada, a Class denotes an inheritance subtree -* Class of `Root` is the class of `Root` and all its children -* Type :ada:`Root'Class` can designate any object typed after type of class of `Root` +* Class of :ada:`Root` is the class of :ada:`Root` and all its children +* Type :ada:`Root'Class` can designate any object typed after type of class of :ada:`Root` .. code:: Ada @@ -21,10 +21,10 @@ Classes -- Child2'Class = {Child2} -- Grand_Child1'Class = {Grand_Child1} -* Objects of type :ada:`Root'Class` have at least the properties of `Root` +* Objects of type :ada:`Root'Class` have at least the properties of :ada:`Root` - - Components of `Root` - - Primitives of `Root` + - Components of :ada:`Root` + - Primitives of :ada:`Root` ----------------- Indefinite Type @@ -62,7 +62,7 @@ Testing the Type of an Object ------------------------------- * The tag of an object denotes its type -* It can be accessed through the `'Tag` attribute +* It can be accessed through the :ada:`'Tag` attribute * Applies to both objects and types * Membership operator is available to check the type against a hierarchy @@ -139,7 +139,7 @@ Abstract Types Ada Vs C++ Relation to Primitives ------------------------ -Warning: Subprograms with parameter of type `Root'Class` are not primitives of `Root` +.. warning:: Subprograms with parameter of type :ada:`Root'Class` are not primitives of :ada:`Root` .. code:: Ada diff --git a/courses/fundamentals_of_ada/180_polymorphism/03-dispatching_and_redispatching.rst b/courses/fundamentals_of_ada/180_polymorphism/03-dispatching_and_redispatching.rst index fd6110534..837f57e78 100644 --- a/courses/fundamentals_of_ada/180_polymorphism/03-dispatching_and_redispatching.rst +++ b/courses/fundamentals_of_ada/180_polymorphism/03-dispatching_and_redispatching.rst @@ -6,7 +6,7 @@ Dispatching and Redispatching Calls on Class-Wide Types (1/3) --------------------------------- -* Any subprogram expecting a `Root` object can be called with a :ada:`Animal'Class` object +* Any subprogram expecting a :ada:`Root` object can be called with a :ada:`Animal'Class` object .. code:: Ada From f71b3ca9a7f1f6a1198c0a9207c7f73934307005 Mon Sep 17 00:00:00 2001 From: Leo Germond Date: Thu, 6 Mar 2025 14:47:10 +0100 Subject: [PATCH 3/4] poly: minor reorder for clarity --- .../180_polymorphism/03-dispatching_and_redispatching.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/courses/fundamentals_of_ada/180_polymorphism/03-dispatching_and_redispatching.rst b/courses/fundamentals_of_ada/180_polymorphism/03-dispatching_and_redispatching.rst index 837f57e78..a14a22fc3 100644 --- a/courses/fundamentals_of_ada/180_polymorphism/03-dispatching_and_redispatching.rst +++ b/courses/fundamentals_of_ada/180_polymorphism/03-dispatching_and_redispatching.rst @@ -27,7 +27,8 @@ Calls on Class-Wide Types (2/3) --------------------------------- * The *actual* type of the object is not known at compile time -* The *right* type will be selected at run-time + + - It will be selected at run-time .. container:: columns From f068345c6a404e6cddb614a4aa7afa210c4b39c2 Mon Sep 17 00:00:00 2001 From: Leo Germond Date: Thu, 6 Mar 2025 14:57:15 +0100 Subject: [PATCH 4/4] fix warning box indent --- .../180_polymorphism/02-classes_of_types.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/courses/fundamentals_of_ada/180_polymorphism/02-classes_of_types.rst b/courses/fundamentals_of_ada/180_polymorphism/02-classes_of_types.rst index 1cd8823a0..03a183c9a 100644 --- a/courses/fundamentals_of_ada/180_polymorphism/02-classes_of_types.rst +++ b/courses/fundamentals_of_ada/180_polymorphism/02-classes_of_types.rst @@ -141,13 +141,13 @@ Relation to Primitives .. warning:: Subprograms with parameter of type :ada:`Root'Class` are not primitives of :ada:`Root` - .. code:: Ada +.. code:: Ada - type Root is tagged null record; - procedure Not_A_Primitive (Param : Root'Class); - type Child is new Root with null record; - -- This does not override Not_A_Primitive! - overriding procedure Not_A_Primitive (Param : Child'Class); + type Root is tagged null record; + procedure Not_A_Primitive (Param : Root'Class); + type Child is new Root with null record; + -- This does not override Not_A_Primitive! + overriding procedure Not_A_Primitive (Param : Child'Class); ---------------------------- 'Class and Prefix Notation