[fpc-devel]Re: fpc-devel digest, Vol 1 #1035 - 2 msgs

Sergey Kosarevsky kosarevsky at chat.ru
Mon Oct 29 15:34:06 CET 2001


Hello fpc-devel-admin,


fdadetn> Send fpc-devel mailing list submissions to
fdadetn>         fpc-devel at lists.freepascal.org

fdadetn> To subscribe or unsubscribe via the web, visit
fdadetn>         http://lists.freepascal.org/mailman/listinfo/fpc-devel
fdadetn> or, via email, send a message with subject or body 'help' to
fdadetn>         fpc-devel-request at lists.freepascal.org
fdadetn> You can reach the person managing the list at
fdadetn>         fpc-devel-admin at lists.freepascal.org

fdadetn> When replying, please edit your Subject line so it is more specific than
fdadetn> "Re: Contents of fpc-devel digest..."


fdadetn> Today's Topics:

fdadetn>   1. A question about old style objects (Pavel V. Ozerski)
fdadetn>   2. Re: A question about old style objects (Peter Vreman)

fdadetn> --__--__--

fdadetn> Message: 1
fdadetn> To: fpc-devel at deadlock.et.tudelft.nl
fdadetn> Organization: Sechenov Institute of Evolutionary Physiology and
fdadetn> Biochemistry, Russian Academy of Science
fdadetn> From: pavel at insect.mail.iephb.ru (Pavel V. Ozerski)
fdadetn> Date: Mon, 29 Oct 2001 11:31:08 +0300 (MSK)
fdadetn> Subject: [fpc-devel]A question about old style objects
fdadetn> Reply-To: fpc-devel at lists.freepascal.org

fdadetn> Hello all,
fdadetn> I found in Russian-language forum (FPC community) a question about possibility to use RTTI with
fdadetn> BP-style objects. First my idea was to answer "no" but I made a smallest test:

fdadetn> {$ifdef FPC}
fdadetn> {$smartlink on}
fdadetn> {$typeinfo off}
fdadetn> {$endif}
fdadetn> type
fdadetn>  t1=object
fdadetn>   constructor Create;
fdadetn>   procedure Test;virtual;
fdadetn>  end;
fdadetn>  t2=object(t1)
fdadetn>   procedure Test;virtual;
fdadetn>  end;
fdadetn> constructor t1.Create;
fdadetn>  begin
fdadetn>  end;
fdadetn> procedure t1.Test;
fdadetn>  begin
fdadetn>   writeln('11111111111111111111111111');
fdadetn>  end;
fdadetn> procedure t2.Test;
fdadetn>  begin
fdadetn>   writeln('22222222222222222222222222');
fdadetn>  end;
fdadetn> type
fdadetn>  p2=^t2;
fdadetn> var
fdadetn>  t:^t1;
fdadetn> begin
fdadetn>  t:=new(p2,create);
fdadetn>  t^.Test;
fdadetn> end.

fdadetn> I became very surprised when I looked into created .exe file and found in it 11111111111111111111111111 string.
fdadetn> BP7, Delphi 3, Delphi 6 cutted unused t1.test method out from .exe, FPC 1.1 (and also VP 2.1) kept it in .exe.
fdadetn> What is the mean, to keep unused BP-objects methods in .exe although old objects are not designed for RTTI?
fdadetn> Or FPC does support RTTI for these objects? Then, IMHO, it is a unnecessary feature because then old-style
fdadetn> objects will be useless (but in Borland products they are useful because allow to write compact high-optimized
fdadetn> applications; a good demonstration is KOL - free Key Object Library for Delphi).

fdadetn> Sincerely, Pavel


fdadetn> --__--__--

fdadetn> Message: 2
fdadetn> To: fpc-devel at deadlock.et.tudelft.nl
fdadetn> From: Peter Vreman <peter at freepascal.org>
fdadetn> Subject: Re: [fpc-devel]A question about old style objects
fdadetn> Date: Mon, 29 Oct 2001 08:56:36 GMT
fdadetn> Reply-To: fpc-devel at lists.freepascal.org

>> Hello all,
>> I found in Russian-language forum (FPC community) a question about possibility to use
fdadetn> RTTI
fdadetn> with
>> BP-style objects. First my idea was to answer "no" but I made a smallest test:
>> 
>> {$ifdef FPC}
>> {$smartlink on}
>> {$typeinfo off}
>> {$endif}
>> type
>>  t1=object
>>   constructor Create;
>>   procedure Test;virtual;
>>  end;
>>  t2=object(t1)
>>   procedure Test;virtual;
>>  end;
>> constructor t1.Create;
>>  begin
>>  end;
>> procedure t1.Test;
>>  begin
>>   writeln('11111111111111111111111111');
>>  end;
>> procedure t2.Test;
>>  begin
>>   writeln('22222222222222222222222222');
>>  end;
>> type
>>  p2=^t2;
>> var
>>  t:^t1;
>> begin
>>  t:=new(p2,create);
>>  t^.Test;
>> end.
>> 
>> I became very surprised when I looked into created .exe file and found in it
fdadetn> 11111111111111111111111111 string.
>> BP7, Delphi 3, Delphi 6 cutted unused t1.test method out from .exe, FPC 1.1 (and also VP
fdadetn> 2.1) kept it in .exe.
>> What is the mean, to keep unused BP-objects methods in .exe although old objects are not
fdadetn> designed for RTTI?
>> Or FPC does support RTTI for these objects? Then, IMHO, it is a unnecessary feature
fdadetn> because then old-style
>> objects will be useless (but in Borland products they are useful because allow to write
fdadetn> compact high-optimized
>> applications; a good demonstration is KOL - free Key Object Library for Delphi).

fdadetn> The VMT of t2 contains a reference to the VMT of t1. And that one contains a reference to
fdadetn> t1.Test.

fdadetn> I don't know an easy solution to remove this kind of unused code. And IMHO it has a very
fdadetn> low priority to be solved.
And why not to add RTTI to standart objects ? (or function, to let
just know the exact object type by pointer to it ?)




-- 
Sergey Kosarevsky
[FC Development Team]
http://fc.freepascal.org
freecommander at aport2000.ru





More information about the fpc-devel mailing list