The CP Language Report has it in section 4, Declaration and scope rules:
Essentially, this means every identifier has to be declared before it can be referenced. The only exception to this rule is forward type declarations, which are provided for in:CP LR wrote:The scope of an object x extends textually from the point of its declaration to the end of the block (module, procedure, or record) to which the declaration belongs and hence to which the object is local.
I noticed, however, that this definition of forward type declarations is way broader than that of the Oberon-2 language. Have it for comparison:CP LR wrote:3. A declaration of a type T containing references to another type T1 may occur at a point where T1 is still unknown. The declaration of T1 must follow in the same block to which T is local;
Now, Oberon's way is necessary to enable mutually referencing or recursive data structures, which is essential. It is also sufficient for that end. I just can't see what advantages are secured with the CP'sdefinition. I can't think up a case where the CP's definition of p.3 would be necessary and essential, or even significantly more convenient that Oberon-2's definition.O2 LR wrote:3. A type T of the form POINTER TO T1 (see 6.4) can be declared at a point where T1 is still unknown. The declaration of T1 must follow in the same block to which T is local;
The following seems impossible in Oberon-2; however, it also seems of low practical importance.
TYPE R = RECORD p: PROCEDURE (a: S) END;
S = ARRAY N OF R;
So, Does anybody know why this definition was broadened? Any ideas or historical reasons?
The CP definition requires a significant (well, somewhat:) complication of the compiler's front-end (DevCPP). I am reworking the front-end for my own purposes, and I'm wondering if reverting to the Oberon way would imply any significant loss.