Skip to content

Commit 597b30b

Browse files
committed
Improving code and description of Quadruple function
1 parent 59f57b9 commit 597b30b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

content/courses/intro-to-ada/chapters/subprograms.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,23 @@ to explicitly store it in a local variable.
227227
return I * 2;
228228
end Double;
229229

230-
Res : Integer := Double (Double (I));
231-
-- ^ Calling the Double
232-
-- function
230+
Res : Integer;
233231
begin
234-
Double (I);
232+
Double (Double (I));
235233
-- ERROR: cannot use call to function
236234
-- "Double" as a statement
237235

236+
Res := Double (Double (I));
237+
-- OK: return value of Double is
238+
-- assigned to Res
239+
238240
return Res;
239241
end Quadruple;
240242

243+
A statement such as :ada:`Double (Double (I));` is wrong because we're not
244+
assigning the return value to a variable |mdash| we can correct this statement
245+
by writing :ada:`Res := Double (Double (I));`.
246+
241247
.. admonition:: In the GNAT toolchain
242248

243249
In GNAT, with all warnings activated, it becomes even harder to ignore the

0 commit comments

Comments
 (0)