Skip to content

Slides/fixes from 6 23 #516

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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b14e180
[!] Replace "blanks" with more technical term "whitespace"
Jul 2, 2025
10637ca
[!] Correcting the statement (-10 is assigned to V, V is not assigned…
Jul 2, 2025
6ab2dfc
[!] Typo fix (should be "Unsigned" not "Signed" for var reference)
Jul 2, 2025
53e0fd9
[-] Remove "So" in order to make this line read less like a dependenc…
Jul 2, 2025
9e55698
[!] Changing "Digits" to lowercase "digits"
Jul 2, 2025
1c1fcf3
[!] Typo fix: Cymk should be Cmyk
Jul 2, 2025
26cad27
[!] Typo fix: Cymk to Cmyk
Jul 2, 2025
3758b64
[!] Changing typename to "identifier" for consistency with earlier sl…
Jul 2, 2025
7cca6aa
[!] Changing type to match diagram (Integer_16 instead of 32)
Jul 2, 2025
7e5bea9
[!] Typo fix for typename (Array_T should be Bit_Array_T)
Jul 2, 2025
b58af49
[!] Typo fix - "staring" to "starting"
Jul 2, 2025
9d4c663
[!] Made quiz question plural since there are multiple answers
Jul 2, 2025
1f1e47d
[-] Remove "attributes" because we are mixing terminology
Jul 2, 2025
d10dbd7
[-] Remove inconsistent terminology (method)
Jul 2, 2025
86a66fc
[!] Typo fix ("Child" should be "Dog")
Jul 2, 2025
606be92
[!] Bulldog should derive from dog
Jul 2, 2025
75c81d1
[!] Reformatting to see if it fixes the "Ada View" bullet missing info
Jul 2, 2025
8bafeb0
[!] Typo fix: change "Input" to "Get_Vector"
Jul 2, 2025
e1a72c7
[!] Adding explicit conversion so that numbers are meaningful
Jul 2, 2025
66fc9d6
[!] Typo fixes
Jul 2, 2025
754a0e7
[!] Rephrasing answer for V assignment
Jul 2, 2025
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 @@ -73,7 +73,7 @@ Operators for Signed Integer Type

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

- So power **must** be :ada:`Integer` ``>= 0``
- Power **must** be :ada:`Integer` ``>= 0``

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

Expand Down Expand Up @@ -181,7 +181,7 @@ Neighbor Attributes for All Scalars
...
Signed := Signed_T'Succ (Signed); -- Signed = 0
...
Unsigned := Unsigned_T'Pred (Unsigned); -- Signed = 255
Unsigned := Unsigned_T'Pred (Unsigned); -- Unsigned = 255

------------------------------------
Min/Max Attributes for All Scalars
Expand Down Expand Up @@ -220,7 +220,7 @@ What happens when you try to compile/run this code?

A. Compile error
B. Run-time error
C. :answer:`V is assigned to -10`
C. :answer:`V is assigned the value -10`
D. Unknown - depends on the compiler

.. container:: animate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Operators for Signed Integer Type

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

- So power **must** be :ada:`Integer` ``>= 0``
- Power **must** be :ada:`Integer` ``>= 0``

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

Expand Down Expand Up @@ -243,7 +243,7 @@ Neighbor Attributes for All Scalars
...
Signed := Signed_T'Succ (Signed); -- Signed = 0
...
Unsigned := Unsigned_T'Pred (Unsigned); -- Signed = 255
Unsigned := Unsigned_T'Pred (Unsigned); -- Unsigned = 255

------------------------------------
Min/Max Attributes for All Scalars
Expand Down Expand Up @@ -282,7 +282,7 @@ What happens when you try to compile/run this code?

A. Compile error
B. Run-time error
C. :answer:`V is assigned to -10`
C. :answer:`V is assigned the value -10`
D. Unknown - depends on the compiler

.. container:: animate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,6 @@ D. ``V4 : Enum_T := Enum_T'Value ("Able Baker Charlie");``

A. Legal
B. Legal - conversion is case-insensitive
C. Legal - leading/trailing blanks are ignored
C. Legal - leading/trailing whitespace is ignored
D. :ada:`Value` tries to convert entire string, which will fail at run-time

Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,5 @@ Which subtype definition is valid?
A. This generates a run-time error because the first enumeral specified is not in the range of :ada:`Weekdays_T`
B. Compile error - no type specified
C. Correct - standalone subtype
D. :ada:`Digits 6` is used for a type definition, not a subtype
D. :ada:`digits 6` is used for a type definition, not a subtype

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ What Is an Array?

.. container:: latex_environment small

:ada:`type <typename> is array (Index_Type) of Component_Type;`
:ada:`type <identifier> is array (Index_Type) of Component_Type;`

where

Expand All @@ -27,7 +27,7 @@ where

.. code:: Ada

type Array_T is array (0 .. 3) of Interfaces.Integer_32;
type Array_T is array (0 .. 3) of Interfaces.Integer_16;

.. image:: array_diagram.svg

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,18 @@ Quiz

Which declaration(s) is (are) legal?

A. ``AAA : Array_T (0..99);``
B. :answermono:`BBB : Array_T (1..32);`
C. :answermono:`CCC : Array_T (17..16);`
D. ``DDD : Array_T;``
A. ``AAA : Bit_Array_T (0..99);``
B. :answermono:`BBB : Bit_Array_T (1..32);`
C. :answermono:`CCC : Bit_Array_T (17..16);`
D. ``DDD : Bit_Array_T;``

.. container:: column

.. container:: animate

Explanations

A. :ada:`Array_T` index is :ada:`Positive` which starts at 1
A. :ada:`Bit_Array_T` index is :ada:`Positive` which starts at 1
B. OK, indices are in range
C. OK, indicates a zero-length array
D. Object must be constrained
2 changes: 1 addition & 1 deletion courses/fundamentals_of_ada/070_subprograms/02-syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Direct Recursion - No Declaration Needed
else
return Get_Vector & Next;
end if;
end Input;
end Get_Vector;

----------------------------
Indirect Recursion Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Writing Limited Constructor Functions
function F return Spin_Lock is
begin
...
-- This is not legal staring with Ada2005
-- This is not legal starting with Ada2005
return Global_X; -- this is a copy
end F;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Quiz

.. container:: column

Which return statement would be legal in ``P.Child.X?``
Which return statement(s) would be legal in ``P.Child.X?``

A. :answermono:`return Object_A;`
B. :answermono:`return Object_B;`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Object-Oriented Programming with Tagged Types
type T is tagged record
...

* Child types can add new components (*attributes*)
* Child types can add new components
* Object of a child type can be **substituted** for base type
* Primitive (*method*) can :dfn:`dispatch` **at run-time** depending on the type at call-site
* Primitive can :dfn:`dispatch` **at run-time** depending on the type at call-site
* Types can be **extended** by other packages

- Conversion and qualification to base type is allowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Special Case for Equality
type Dog is new Animal with null record;
overriding function "=" (Left : Dog; Right : Dog) return Boolean;
Animal_1, Animal_2 : Animal;
Dog_1, Dog_2 : Child;
Dog_1, Dog_2 : Dog;
Any_Animal_1 : Animal'Class := Animal_1;
Any_Animal_2 : Animal'Class := Animal_2;
Dog_Animal : Animal'Class := Dog_1;
Expand Down Expand Up @@ -79,7 +79,7 @@ Controlling Result (1/2)
type Dog is new Animal with null record;
-- OK, Feed_Treats is implicitly inherited

type Bulldog is new Animal with record
type Bulldog is new Dog with record
Has_Underbite : Boolean;
end record;
-- ERROR no implicitly inherited function Feed_Treats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Passing Structures As Parameters
* Ada View

.. code:: Ada

type Enum is (E1, E2, E3) with Convention => C;
type Rec is record
A, B : int;
Expand Down
6 changes: 3 additions & 3 deletions courses/fundamentals_of_ada/labs/answers/030_basic_types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ procedure Main is

type Degrees_T is mod 360;

type Cymk_T is (Cyan, Magenta, Yellow, Black);
type Cmyk_T is (Cyan, Magenta, Yellow, Black);

Number_Of_Tests : Number_Of_Tests_T;
Test_Score_Total : Test_Score_Total_T;

Angle : Degrees_T;

Color : Cymk_T;
Color : Cmyk_T;
--Declarations

--Implementation
Expand All @@ -34,7 +34,7 @@ begin
-- operations / attributes
Test_Score_Total := Test_Score_Total / Test_Score_Total_T (Number_Of_Tests);
Angle := Angle + 359;
Color := Cymk_T'Pred (Cymk_T'Last);
Color := Cmyk_T'Pred (Cmyk_T'Last);

Put_Line (Test_Score_Total'Image);
Put_Line (Angle'Image);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ procedure Main is
Object_Feet : constant Data_T :=
(Distance => 6_000.0,
Distance_Type => Feet,
Seconds => One_Minute_In_Seconds);
Seconds => Interfaces.C.C_float(One_Minute_In_Seconds));
Object_Meters : constant Data_T :=
(Distance => 3_000.0,
Distance_Type => Meters,
Seconds => One_Hour_In_Seconds);
Seconds => Interfaces.C.C_float(One_Hour_In_Seconds));
Object_Miles : constant Data_T :=
(Distance => 1.0,
Distance_Type =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ procedure Main is
-- type Degrees_T is ?
-- Angle : Degrees_T;

-- type Cymk_T is ?
-- Color : Cymk_T;
-- type Cmyk_T is ?
-- Color : Cmyk_T;

begin

Expand Down
Loading