|
From: | Alexey Ulasevich |
Subject: | Re: Fwd: cannot declare function |
Date: | Sun, 13 Oct 2024 14:44:06 +0300 |
User-agent: | Mozilla Thunderbird |
Yes. Thanks.
I investigated "The Programming Language Modula-2" more careful, like I got from "10. Procedure declarations" and "10.1 Formal parameters", when procedure does not return any result we can miss brackets. So next code also Ok (but with brackets it's really more readable):
Forgot GM2 distribution list ...
-------- Weitergeleitete Nachricht --------
Betreff: Re: cannot declare function Datum: Sun, 13 Oct 2024 13:16:31 +0200 Von: Michael Riedl <udo-michael.riedl@t-online.de> An: Alexey Ulasevich <alexey.ulasevich@gmail.com>
Alexey,
a procedure needs an argument list - though that can be empty, suppose that was your intention.
I would write your example as:
MODULE proc_test;
PROCEDURE Calc() : CARDINAL;
BEGIN
RETURN 2;
END Calc;
VAR ival : CARDINAL;
BEGIN
ival := Calc();
END proc_test.
with the brackets "()" after "Calc" it should compile. And also when calling this procedure use the brackets.
This, by the way, increases readability, as everybody immediately will see that "Calc" is a function, not a variable or constant.
Gruß
Michael
Am 13.10.24 um 13:03 schrieb Alexey Ulasevich:
MODULE proc_test;PROCEDURE Calc : CARDINAL;BEGINRETURN 2;END Calc;BEGINEND proc_test.
[Prev in Thread] | Current Thread | [Next in Thread] |