Skip to content

2025-03-25 #509

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 3 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 @@ -40,7 +40,8 @@ Declarations

- ``N`` is usually an :dfn:`identifier`

* Declaration **must precede** use
.. warning:: Declaration **must precede** use

* **Some** implicit declarations

- **Standard** types and operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Identifiers
- `SpacePerson` |equivalent| `SPACEPERSON`
- ...but **different** from `Space_Person`

* Reserved words are **forbidden**
.. warning:: Reserved words are **forbidden**

----------------
Reserved Words
Expand Down
3 changes: 2 additions & 1 deletion courses/fundamentals_of_ada/020_declarations/03-literals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ Decimal Numeric Literals
numeral [.numeral] E [+numeral|-numeral]
numeral ::= digit {['_'] digit}

* Underscore is not significant
.. tip:: Underscore is **not** significant and used for grouping

* **E** (exponent) must always be integer
* Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ Numeric Literals Are Universally Typed

* Compiler handles typing

- No bugs with precision
.. tip:: No bugs with precision

.. code:: Ada
.. code:: Ada

X : Unsigned_Long := 0;
Y : Unsigned_Short := 0;
X : Unsigned_Long := 0;
Y : Unsigned_Short := 0;

----------------------------------------
Literals Must Match "Class" of Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ Named Number Benefit
* Evaluation at **compile time**

- As if **used directly** in the code
- **Perfect** accuracy

.. code:: Ada
.. tip:: They have **perfect** accuracy

Named_Number : constant := 1.0 / 3.0;
Typed_Constant : constant Float := 1.0 / 3.0;
.. code:: Ada

Named_Number : constant := 1.0 / 3.0;
Typed_Constant : constant Float := 1.0 / 3.0;

.. container:: latex_environment footnotesize

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ Scope and "Lifetime"
----------------------

* Object in scope |rightarrow| exists
* No *scoping* keywords

- C's :c:`static`, :c:`auto` etc...
.. warning:: No *scoping* keywords (C's :c:`static`, :c:`auto` etc...)

.. image:: block_scope_example.jpeg
:height: 50%
Expand Down Expand Up @@ -101,9 +100,11 @@ Overcoming Hiding

- Needs named scope

* Homographs are a *code smell*
.. warning::

- May need **refactoring**...
* Homographs are a *code smell*

- May need **refactoring**...

.. code:: Ada

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Strong Typing

- **Check** of values and operations
- Easy for a computer
- Developer can focus on **earlier** phase: requirement

.. tip:: Developer can focus on **earlier** phase: requirement

----------------------------------------
Strongly-Typed Vs Weakly-Typed Languages
Expand Down Expand Up @@ -198,7 +199,8 @@ Type Model Run-Time Costs
* **Same performance** for identical programs

- Run-time type checks can be disabled
- Compile-time check is *free*

.. note:: Compile-time check is *free*

.. container:: columns

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ Predefined Signed Integer Types
- Guaranteed ranges: :ada:`Short_Integer` ``<=`` :ada:`Integer` ``<=`` :ada:`Long_Integer`
- Ranges are all **implementation-defined**

* Portability not guaranteed
.. warning::

- But may be difficult to avoid
Portability not guaranteed

* But may be difficult to avoid

---------------------------------
Operators for Signed Integer Type
Expand All @@ -67,12 +69,13 @@ Operators for Signed Integer Type
:multiplying operator: :ada:`* | / | mod | rem`
:highest precedence operator: :ada:`** | abs`

* *Note*: for exponentiation :ada:`**`
.. note::

- Result will be a signed integer
- So power **must** be :ada:`Integer` ``>= 0``
Exponentiation :ada:`**` result will be a signed integer

* Division by zero |rightarrow| :ada:`Constraint_Error`
- |rightarrow| power **must** be :ada:`Integer` ``>= 0``

.. warning:: Division by zero |rightarrow| :ada:`Constraint_Error`

------------------------
Signed Integer Overflows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ Predefined Signed Integer Types
- Guaranteed ranges: :ada:`Short_Integer` ``<=`` :ada:`Integer` ``<=`` :ada:`Long_Integer`
- Ranges are all **implementation-defined**

* Portability not guaranteed
.. warning::

- But may be difficult to avoid
Portability not guaranteed

- But may be difficult to avoid

---------------------------------
Operators for Signed Integer Type
Expand All @@ -67,12 +69,13 @@ Operators for Signed Integer Type
:multiplying operator: :ada:`* | / | mod | rem`
:highest precedence operator: :ada:`** | abs`

* *Note*: for exponentiation :ada:`**`
.. note::

Exponentiation :ada:`**` result will be a signed integer

- Result will be a signed integer
- So power **must** be :ada:`Integer` ``>= 0``
- |rightarrow| power **must** be :ada:`Integer` ``>= 0``

* Division by zero |rightarrow| :ada:`Constraint_Error`
.. warning:: Division by zero |rightarrow| :ada:`Constraint_Error`

------------------------
Signed Integer Overflows
Expand Down Expand Up @@ -119,7 +122,7 @@ Modular Types
* **Unsigned** values
* Adds operations and attributes

* Typically **bit-wise** manipulation
.. note:: Typically **bit-wise** manipulation

* Syntax

Expand Down
11 changes: 7 additions & 4 deletions courses/fundamentals_of_ada/030_basic_types/07-real_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ Predefined Floating Point Types
- :ada:`Long_Float` ``>= 11`` digits

* General-purpose
* Best to **avoid** predefined types

- Loss of **portability**
- Easy to avoid
.. tip::

It is best, and easy, to **avoid** predefined types

- Loss of **portability**

-------------------------------
Floating Point Type Operators
Expand Down Expand Up @@ -140,7 +142,8 @@ Numeric Types Conversion
* Special rule: can always convert between numeric types

- Explicitly
- :ada:`Float` |rightarrow| :ada:`Integer` causes **rounding**

.. warning:: :ada:`Float` |rightarrow| :ada:`Integer` causes **rounding**

.. code:: Ada

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Subtype

- :ada:`Type_Name` is an existing :ada:`type` or :ada:`subtype`

* If no constraint |rightarrow| type alias
.. note:: If no constraint |rightarrow| type alias

-----------------
Subtype Example
Expand Down
12 changes: 5 additions & 7 deletions courses/fundamentals_of_ada/standard_course.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
020_declarations.rst
030_basic_types.rst
040_statements.rst
080_expressions.rst
050_array_types.rst
060_record_types.rst
070_subprograms.rst
075_type_derivation.rst
080_expressions.rst
090_overloading.rst
075_type_derivation.rst
190_exceptions.rst
280_low_level_programming.rst
100_packages.rst
110_private_types.rst
120_limited_types.rst
130_program_structure.rst
135_visibility.rst
140_access_types.rst
160_genericity.rst
170_tagged_derivation-intro.rst
180_polymorphism.rst
190_exceptions.rst
230_interfacing_with_c.rst
270_introduction_to_contracts.rst
240_tasking.rst
920_reference_material.rst