Skip to content

Mr/127 create an introduction to polymorphism rst #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -139,15 +139,15 @@ 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
.. 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
Loading