Discussion:
Assignment 5 - Naming convention for procedures
(too old to reply)
Johnny Yip
2004-07-09 02:30:42 UTC
Permalink
Hi,

From the spec
"it is legal to name a variable the same as the procedure
which contains its declaration (i.e., a variable main within the main
procedure is valid)"

But what about following situation?

int A() begin ... end;
...
#main procedure
begin
int A;
A <- A(); # Can I have duplicate ID like this?
end;

I figure that there won't be naming conflicts in terms of using them in
expressions (procedures calls must contain "()" anyway so they will differ
from variable), but not sure if it is OK in terms of the SL spec.

Thanks
Johnny
Troy Mark Gonsalves
2004-07-09 19:59:13 UTC
Permalink
Looks ok to me...it'll take extra effort to catch this...and it's really
not a problem. So, sure, allow a proc A() and a variable A.

Troy
Post by Johnny Yip
Hi,
From the spec
"it is legal to name a variable the same as the procedure
which contains its declaration (i.e., a variable main within the main
procedure is valid)"
But what about following situation?
int A() begin ... end;
...
#main procedure
begin
int A;
A <- A(); # Can I have duplicate ID like this?
end;
I figure that there won't be naming conflicts in terms of using them in
expressions (procedures calls must contain "()" anyway so they will differ
from variable), but not sure if it is OK in terms of the SL spec.
Thanks
Johnny
Jaewook Chung
2004-07-09 21:05:19 UTC
Permalink
Yes, it is acceptable according to SL language specification.
Post by Johnny Yip
Hi,
From the spec
"it is legal to name a variable the same as the procedure
which contains its declaration (i.e., a variable main within the main
procedure is valid)"
But what about following situation?
int A() begin ... end;
...
#main procedure
begin
int A;
A <- A(); # Can I have duplicate ID like this?
end;
I figure that there won't be naming conflicts in terms of using them in
expressions (procedures calls must contain "()" anyway so they will differ
from variable), but not sure if it is OK in terms of the SL spec.
Thanks
Johnny
Loading...