Do procedures and variables share namespace?

4 views
Skip to first unread message

Margus Freudenthal

unread,
Mar 2, 2011, 6:52:26 AM3/2/11
to ldta-2011-to...@googlegroups.com
Hello,

does the Oberon-0 have single namespace for all the identifiers or does
it have separate namespace for procedures and normal variables? More
specifically, does the following program work?

PROCEDURE Foo(x: INTEGER);
VAR Foo: INTEGER;
BEGIN
Foo := 10;
Foo(Foo)
END Foo;

I searched the book, but it doesn't seem to discuss this issue
explicitly. Does anyone have any insight on this? I vaguely remember
that Pascal had separate namespaces, but I am not sure.

--
Margus

Tony Sloane

unread,
Mar 2, 2011, 6:55:33 PM3/2/11
to ldta-2011-to...@googlegroups.com

Looking at the symbol table code (NewObj, find, etc) in the parser module (OSP, page 114) seems to indicate that there is only one name space. All named things seem to be represented by objects created by NewObj and looked up using find.

Tony

Eric Van Wyk

unread,
Mar 3, 2011, 3:00:24 AM3/3/11
to ldta-2011-to...@googlegroups.com
Hi -

Tony is right to look at the code for the answer. One might also
consider what would happen if functions were added to Oberon0 in
addition to the procedures that are there. Since procedures with no
arguments can be called using only their name and no empty parenthesis
(as in "MyProcWithNoArgs ;"), then functions with no arguments would
also be called without parenthesis. Thus having separate names spaces
for function names and variable names would be problematic. So that
may also lead you to believe that procedures and variables do not have
separate name spaces.

Cheers,
Eric

Reply all
Reply to author
Forward
0 new messages