[fpc-pascal] Re: Procedures in records not supported :(

John jszcmpr at netspace.net.au
Sun Feb 10 02:14:25 CET 2008


Skybuck Flying wrote:
> Not quite buster !
>
> // *** Demo problem begin ***
>
> type
> TmyRecord = record
>  A,B,C,D,E,F : integer;
> end;
>
> TmyObject = object
>  A,B,C,D,E,F : integer;
>  
>  procedure Test;
> end;
>
> procedure TmyObject.Test;
> begin
> A := 5;
> end;
>
>
> begin
> writeln( SizeOf(TmyRecord) );
> writeln( SizeOf(TmyObject) );
>
> TmyObject.Test; // not allowed, does not compile
>
> end.
>
> // *** Demo problem end ***
>
> The test routine of Tobject cannot be called directly.
>
> It needs probably two things to work:
>
> 1. A object instance variable declaration
If you define a record type, you still declare a variable of that type 
before you use it, don't you ?
>
> 2. And probably a constructor and destructor call.
No, not unless you include virtual methods.  That is one of the 
differences between the "old" 'object' definition, introduced in object 
pascal pre delphi, and the 'class' definition in Delphi.
>
> This is very bad because it adds much complexity and overhead.
>
> I don't want to manage memory/objects, constructions/destructions.
>
> I just wanna call:
>
> TmyRecord.Test;
Do you really want to call the procedure of the record type, or of a 
variable of that type ?
>
> Without having to instantiate anything.
>
> That's exactly what Delphi allows me to do.
>
> So it's definetly a new future never seen before ! ;)
>
> And to boldly go where no-one has gone before ! ;) =D
>
> Startrek-tng allll the way baby ;)
>
> Bye,
>  Skybuck.
Re Mail threads, in reply to a different message, I have no trouble 
seeing the threads in Thunderbird, what mail client are you using ?

cheers,
John Sunderland



More information about the fpc-pascal mailing list