[fpc-pascal] Empty record inside another record ?

Tiziano De Togni tizzziano at tiscali.it
Tue Feb 19 09:00:23 CET 2008


Florian Klaempfl ha scritto:
> Skybuck Flying schrieb:
>> One drawback of objects already discovered:
>>
>> Objects cannot have the same field identifiers.
> 
> Indeed, especially if you want to win an obfuscation contest.

ok, this is true for object type, but it should not be extended to class
types. Look at this example taken from Delphi Help:

type
   TAncestor = class
     Value: Integer;
   end;

   TDescendant = class(TAncestor)
     Value: string;  // hides the inherited Value field
   end;

var
   MyObject: TAncestor;

begin
   MyObject := TDescendant.Create;
   // MyObject.Value := 'Hello!';  // error
   TDescendant(MyObject).Value := 'Hello!';  // works!
end;

it compiles correctly in Delphi (5 and 7) but FPC (v2.2.0 - compiled 
with Params Values=" -S2cdgi -OG1 -gl -WG -vewnhi") still says
that there is a duplicate identifier "Value"...

am I correct?

-- 
tiziano
______________________________________
http://digilander.libero.it/tizzziano/



More information about the fpc-pascal mailing list