Discussion:
Phase10: Procedure Calls
(too old to reply)
Pritesh Bodalia
2004-07-14 04:42:19 UTC
Permalink
Suppose the source looks like this:

int blah1 ()
begin
char y;
y<-blah2();
end;

void blah2 ( int x)
begin
return;
end;

begin
blah1();
end;

If we come across a proc_call where that procedure has not been defined
yet what do we do? In this case, when we are compiling blah1 we dont know
that blah2 has parameters and we dont know what type it will return if
anything at all. So when we do the assignment to y, we cant check for
types.
Danny Su
2004-07-14 00:33:44 UTC
Permalink
You should generate an error at this point.
All procedures must be declared before they're called.
Troy Mark Gonsalves
2004-07-20 17:55:07 UTC
Permalink
Like Danny said, this is an error.
You have to declare the procedure before calling it.

This creates an issue for a recursion procedure, but I leave that to you
to figure out (it's a bonus afterall).

Troy
Post by Pritesh Bodalia
int blah1 ()
begin
char y;
y<-blah2();
end;
void blah2 ( int x)
begin
return;
end;
begin
blah1();
end;
If we come across a proc_call where that procedure has not been defined
yet what do we do? In this case, when we are compiling blah1 we dont know
that blah2 has parameters and we dont know what type it will return if
anything at all. So when we do the assignment to y, we cant check for
types.
Continue reading on narkive:
Loading...