Hi Folks,
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?
Yours,
Markus
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?
Feature. The program is flat out wrong and gpc is telling you how and where. Replace "result" with "bar" in bar, and "bar" with "foo = bar" in foo, and it should compile and run.
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
Frank Heckenbach dixit:
Function foo: integer; Procedure bar;
Notice, though, that if it does, it's somewhat confusing (if both `foo' and `bar' are functions
But they aren't in this example, which both you and CBFalconer seemed to not have seen.
bye, //mirabile
Thorsten Glaser wrote:
Frank Heckenbach dixit:
Function foo: integer; Procedure bar;
Notice, though, that if it does, it's somewhat confusing (if both `foo' and `bar' are functions
But they aren't in this example, which both you and CBFalconer seemed to not have seen.
OK, you don't only know what I get or don't get, now you also know what I saw or didn't see? (I'll leave it to Chuck to reply for himself if he bothers, though I can't see even remotely what this comment has do to with his previous reply.)
But if you read further what I wrote, you could notice:
[...], one implicit `Result' probably shadows the other -- please try this case with Delphi as well),
Any idea what I could have meant by writing "if" and "this case *as well*"?
Frank
On 9 Feb 2005 at 8:10, Markus Gerwinski wrote:
Hi Folks,
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?
The program should compile, because it compiles under Delphi, and the "Result" stuff is there for Delphi compatibility (although I think that Delphi should really not compile such a thing, that is beside the point).
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/