Peter N Lewis wrote:
At 9:26 +0200 5/7/05, Frank Heckenbach wrote:
Looking at OOE ... AFAICS, their solution to this problem is the following:
: 6.1.5 Deferred class definitions. : : A class name can be declared before its structure and contents are defined. : This is specified by: : : TYPE : name = [ kind ] CLASS .. END; : : NOTE: In the above, ".." is a symbol. : : Later in the same type-definition-part, there must be a type definition with : the same name that specifies the contents and structure of the class. A class : cannot be used in a class-inheritance-list before its complete definition is : specified.
I think this could be reasonable. Similarly to a forward-defined pointer type, this forward-defines a reference type.
We could probably add the same with `object' references. (Waldek?)
Assuming it worked for object references, that would have solved my problem, as I could have added
MyObjectA = object .. end; MyObjectB = object .. end;
to the start of the type declaration and all would be well.
Yes, I think so.
I imagine that would only work with non object reference if GPC was smart enough to know that the size was unknown and therefore it could only be used as parts of types where its size was not needed (eg ^MyObjectA). Whether that would be useful, I don't know, unless it could also cope with a case like:
What are non-object references? I only know var-parameters and in a sense, absolute-variables, both don't apply here.
MyObjectA = object .. end; MyProc = procedure( var obj: MyObjectA ); MyObjectA = object f: MyProc; end;
But that would all be much harder than the case of class/reference object where the type size is known to match SizeOf(Ptr) even though the type is not defined fully yet, just like explicit forward pointer definitions.
Oh, you mean non-reference objects, I suppose. In this case, I don't think it should work. BP doesn't allow the above, though BP (and GPC as well) allow this:
program Foo;
type MyObjectA = object f: procedure( var obj: MyObjectA ); end;
begin end.
And even this (GPC with the usual warning about value object parameters):
program Foo;
type MyObjectA = object f: procedure( obj: MyObjectA ); end;
begin end.
Frank