@@ -3306,8 +3306,8 @@ example to accommodate this requirement:
33063306 V : Float;
33073307 end record;
33083308
3309- function Read_Info (D : Device)
3310- return Device_Info;
3309+ function Current_Info (D : Device)
3310+ return Device_Info;
33113311
33123312 private
33133313
@@ -3342,8 +3342,8 @@ example to accommodate this requirement:
33423342 D := Device_On;
33433343 end Turn_On;
33443344
3345- function Read_Info (D : Device)
3346- return Device_Info is
3345+ function Current_Info (D : Device)
3346+ return Device_Info is
33473347 (D.Info);
33483348
33493349 end Devices;
@@ -3361,26 +3361,26 @@ this device by turning it on and off, and by retrieving information from it:
33613361 I : Device_Info;
33623362 begin
33633363 Turn_On (D);
3364- I := Read_Info (D);
3364+ I := Current_Info (D);
33653365
33663366 Turn_Off (D);
33673367
33683368 -- The following call raises
33693369 -- an exception at runtime
33703370 -- because D is turned off.
3371- I := Read_Info (D);
3371+ I := Current_Info (D);
33723372 end Show_Device;
33733373
33743374In this example, by using the variant part, we're preventing information
3375- retrieved by an inappropriate call to the :ada: `Read_Info ` function from being used
3375+ retrieved by an inappropriate call to the :ada: `Current_Info ` function from being used
33763376elsewhere in the application. In fact, if the device is turned off, a call to
3377- :ada: `Read_Info ` raises the :ada: `Constraint_Error ` exception because the
3377+ :ada: `Current_Info ` raises the :ada: `Constraint_Error ` exception because the
33783378:ada: `Info ` component isn't accessible. We see that effect in the
3379- :ada: `Show_Device ` procedure: the call to :ada: `Read_Info ` *fails * (by raising
3379+ :ada: `Show_Device ` procedure: the call to :ada: `Current_Info ` *fails * (by raising
33803380an exception) when the device has just been turned off.
33813381
33823382To avoid exceptions at runtime, we must check the device's state before
3383- calling :ada: `Read_Info `:
3383+ calling :ada: `Current_Info `:
33843384
33853385.. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Records.Variant_Parts.Device
33863386
@@ -3393,19 +3393,19 @@ calling :ada:`Read_Info`:
33933393 Turn_On (D);
33943394
33953395 if D.State = On then
3396- I := Read_Info (D);
3396+ I := Current_Info (D);
33973397 end if;
33983398
33993399 Turn_Off (D);
34003400
34013401 if D.State = On then
3402- I := Read_Info (D);
3402+ I := Current_Info (D);
34033403 end if;
34043404 end Show_Device;
34053405
34063406Now, no exception is raised, as we only retrieve information from
34073407the device when it is turned on |mdash | that is, we only call the
3408- :ada: `Read_Info ` function when the :ada: `State ` discriminant of the object is
3408+ :ada: `Current_Info ` function when the :ada: `State ` discriminant of the object is
34093409set to :ada: `On `.
34103410
34113411
@@ -3430,8 +3430,8 @@ that interfaces with that sensor:
34303430 Info_1 : Float := 0.0;
34313431 end record;
34323432
3433- function Read_Info (S : Sensor)
3434- return Sensor_Info;
3433+ function Current_Info (S : Sensor)
3434+ return Sensor_Info;
34353435
34363436 procedure Display (SI : Sensor_Info);
34373437
@@ -3445,8 +3445,8 @@ that interfaces with that sensor:
34453445
34463446 package body Sensors is
34473447
3448- function Read_Info (S : Sensor)
3449- return Sensor_Info is
3448+ function Current_Info (S : Sensor)
3449+ return Sensor_Info is
34503450 ((Info_1 => 4.0));
34513451 -- ^^^^
34523452 -- NOTE: we're returning dummy
@@ -3461,7 +3461,7 @@ that interfaces with that sensor:
34613461 end Sensors;
34623462
34633463The :ada: `Sensor ` type from the :ada: `Sensors ` package has two subprograms: the
3464- :ada: `Read_Info ` function and the :ada: `Display ` procedure. We use those
3464+ :ada: `Current_Info ` function and the :ada: `Display ` procedure. We use those
34653465subprograms in the :ada: `Show_Sensors ` procedure below:
34663466
34673467.. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Records.Variant_Parts.Sensors
@@ -3473,7 +3473,7 @@ subprograms in the :ada:`Show_Sensors` procedure below:
34733473 procedure Show_Sensors is
34743474 S1 : Sensor;
34753475 begin
3476- Display (Read_Info (S1));
3476+ Display (Current_Info (S1));
34773477 end Show_Sensors;
34783478
34793479Now, let's assume that a new model of this sensor is available, and it has
@@ -3510,8 +3510,8 @@ store the additional information. For example:
35103510 end case;
35113511 end record;
35123512
3513- function Read_Info (S : Sensor)
3514- return Sensor_Info;
3513+ function Current_Info (S : Sensor)
3514+ return Sensor_Info;
35153515
35163516 procedure Display (SI : Sensor_Info);
35173517
@@ -3527,8 +3527,8 @@ store the additional information. For example:
35273527
35283528 package body Sensors is
35293529
3530- function Read_Info (S : Sensor)
3531- return Sensor_Info is
3530+ function Current_Info (S : Sensor)
3531+ return Sensor_Info is
35323532 begin
35333533 -- Using dummy info for the information
35343534 -- returned by the function
@@ -3541,7 +3541,7 @@ store the additional information. For example:
35413541 Info_1 => 8.0,
35423542 Info_2 => 6.0));
35433543 end case;
3544- end Read_Info ;
3544+ end Current_Info ;
35453545
35463546 procedure Display (SI : Sensor_Info) is
35473547 begin
@@ -3562,8 +3562,8 @@ discriminant was added to the :ada:`Sensor_Info` type. If the model is set to
35623562version 2 for a specific sensor (i.e., :ada: `Model = Sensor_V2 `), a new
35633563component (:ada: `Info_2 `) is available.
35643564
3565- The :ada: `Read_Info ` and :ada: `Display ` subprograms have been adapted to
3566- take this new model into account. In the :ada: `Read_Info ` function, we return
3565+ The :ada: `Current_Info ` and :ada: `Display ` subprograms have been adapted to
3566+ take this new model into account. In the :ada: `Current_Info ` function, we return
35673567information for the newer model of the sensor. In the :ada: `Display `
35683568procedure, we display the additional information provided by the newer model.
35693569
@@ -3579,7 +3579,7 @@ Note that the original test application that makes use of the sensor
35793579 procedure Show_Sensors is
35803580 S1 : Sensor;
35813581 begin
3582- Display (Read_Info (S1));
3582+ Display (Current_Info (S1));
35833583 end Show_Sensors;
35843584
35853585Because we have a default value for the discriminant of the :ada: `Sensor ` type,
@@ -3601,8 +3601,8 @@ sensor:
36013601 S1 : Sensor;
36023602 S2 : Sensor (Sensor_V2);
36033603 begin
3604- Display (Read_Info (S1));
3605- Display (Read_Info (S2));
3604+ Display (Current_Info (S1));
3605+ Display (Current_Info (S2));
36063606 end Show_Sensors;
36073607
36083608In the updated version of the :ada: `Show_Sensors ` procedure, we're now using
0 commit comments