At 12:32 +0200 7/7/05, Frank Heckenbach wrote:
Peter N Lewis wrote:
Peter N Lewis wrote:
CW takes the approach that any unknown type identifier it sees in a type definition is pointer sized (a pointer or object) and must be defined by the end of the type block.
This would be wrong, as pointer targets can (according to standard Pascal and all other dialects) be of any type and may be forward-referenced, e.g. in this example, b is probably not pointer-sized, but it must work:
program Foo;
type a = ^b; b = array [1 .. 1000] of Integer;
CW handles this as well. So it handles the two cases, an unknown identifier, and forward pointer references (as in, an unknown identifier after ^)
The handling of unknown identifiers is for the other cases (other than ^unknown).
Actually, I just tried to figure out what BP does. It seems to be buggy. `{$T+}' is supposed to enforce strict type-checking with the address operator (@), but in this case is seems to allow the wrong assignment, and reject the right one. Anyway, bar really seems to be a pointer to a reference, so it would not help us here.
I'm not sure about BP, but I know CW often requires the @ before a procedure name for an assignment to a procedural variable to remote the ambiguity of whether to call it or not - and then introduces the new ambiguity of whether it is a procedural pointer or a pointer to a procedure pointer. Ie, in CW:
function doit( a: Integer ): Integer; begin return 1; end; type proc = function ( a: Integer ) : Integer; var a: proc; begin a := @doit; WriteLn( a( 10 ) ); // prints 1 end;
Perhaps BP does something equally weird.
It requires the `class' keyword. There is a problem, that `class' keyword is (ATM) not accepted in Mac Pascal mode. It would be easy to implement syntax with `object' as an alternate keword,
As Gale wrote, the Mac Pascal syntax seems to be `object; forward;'. So if you can add this without conflicts, this would be preferable, I think.
Any (or all) of the different syntax is fine by me.
but than we would have to decide what to do if `object' is used in a forward declaration in one mode, but the proper declaration uses different mode.
This should be an error IMHO. Why should we allow such useless obscurities?
Agreed. Indeed, I would think it would be an error to forward declare (or define after a forward declare) any non-reference object.
Enjoy, Peter.