Markus Gerwinski wrote:
compiling the program
Program Test;
var x: integer;
Function foo: integer;
Procedure bar; begin (* bar *) result:= 7; end (* bar *);
begin (* foo *) bar; end (* foo *);
begin x:= foo; end.
yields an error message
test.pas: In procedure `bar': test.pas:14: error: invalid access to `Result' test.pas: In function `foo': test.pas:20: error: result of function not assigned
Bug or feature?
An interesting case indeed. Since `Result' is a Delphi feature, we probably should check if Delphi allows this, and if so do so as well.
Notice, though, that if it does, it's somewhat confusing (if both `foo' and `bar' are functions, one implicit `Result' probably shadows the other -- please try this case with Delphi as well), and error-prone (in your example, if you later decide to make `bar' a function with an integer type result, the code would silently change its meaning).
BTW, Chuck, I'm well aware that you prefer to use only ISO 7185 features, and if that's ok for you, fine. But it's really not necessary to point this out each time someone mentions an feature of ISO 10206 or another dialect. Why don't you save yourself the annoyance and just skip such threads?
Frank