[Oberon] Oxford Oberon-2 Compiler and local procedures
martinbishop at bellsouth.net
Thu Nov 27 05:20:28 MET 2008
I translated some Pascal code for "deep binding" (aka closures) into Oberon.
TYPE Function = PROCEDURE ();
PROCEDURE A(I: INTEGER; P: Function);
IF I > 1 THEN
And here is the output from OO2C:
martin at thinkpad:~/Code/Oberon$ oo2c --make Closure.Mod
martin at thinkpad:~/Code/Oberon$ cd bin
martin at thinkpad:~/Code/Oberon/bin$ ./Closure
which is correct.
However, here is the output of the same program (renamed to Closure.m so
the compiler accepts it) in the Oxford Oberon-2 Compiler (obc):
martin at thinkpad:~$ obc -o Closure Closure.m
"Closure.m", line 19: local procedure 'B' may not be used as a procedure
> A(2, B);
Why does it not allow B to be used as a procedure value?
After a little digging in the obc manual, I find a section that says:
The scope of a procedure includes the bodies of all procedures
defined at the same nesting level, without the need for “forward
declarations”. In fact, such forward declarations are not permitted.
I’m guessing this is what is screwing it up, but I don’t really know
what that means.
Does anyone have an idea as to why oo2c seems to compile the code just
fine, and obc does not?
More information about the Oberon