BP OOP problem

Prof A Olowofoyeku (The African Chief) chiefsoft at bigfoot.com
Tue May 18 21:53:20 CEST 2004


On 18 May 2004 at 4:03, Frank Heckenbach wrote:

> I just found another problem in BP's OOP. In the following program,
> `o.f' in oo.p is ambiguous. It could mean field f of the field o, or
> function f of the parent type o. Both BP and GPC (currently) do the
> former (i.e., say 99).
> 
> I noticed this because the OOE draft forbids this case by requiring that
> object fields don't clash with parent type names.
> 
> We do we do here? Allow it in BP mode with a warning, error
> otherwise?
> 
> program Foo;
> 
> type
>   o = object
>     function f: Integer;
>   end;
> 
>   oo = object (o)
>     o: record
>          f: Integer
>        end;
>     procedure p;
>   end;
> 
> function o.f: Integer;
> begin
>   f := 42
> end;
> 
> procedure oo.p;
> begin
>   WriteLn (o.f)
> end;
> 
> var
>   v: oo;
> 
> begin
>   v.o.f := 99;
>   v.p
> end.

This looks okay to me (i.e., I would expect "99"). The "Writeln (o.f)" 
clearly refers to the "f" field of the record "o". The fact that it is 
qualified makes it clear (to me at least). It could not possible refer 
to the function "f" in the parent object, because using the base name 
of the parent object in this manner must generate a compiler error.
On the other hand, "Writeln (f)" would refer to the function "f" in the 
parent object. In other words, I don't see any ambiguity here - and 
neither does the compiler, because, in fact, there is no ambiguity.

Best regards, The Chief
--------
Prof. Abimbola A. Olowofoyeku (The African Chief) 
web:  http://www.bigfoot.com/~african_chief/




More information about the Gpc mailing list