[fpc-pascal] Empty record inside another record ?

Skybuck Flying skybuck2000 at hotmail.com
Fri Feb 29 15:16:26 CET 2008

There is another major drawback to your supposedly better method:

Object inheritance forces all fields to be accessable from the root:

SomeRoot.SomeField := ...;

While nesting has nice grouping:

SomeRoot.SomeHeader.SomeOtherHeader.SomeField := 5;


----- Original Message ----- 
From: "Daniël Mantione" <daniel.mantione at freepascal.org>
To: "FPC-Pascal users discussions" <fpc-pascal at lists.freepascal.org>
Sent: Saturday, February 16, 2008 5:24 PM
Subject: Re: [fpc-pascal] Empty record inside another record ?

Op Fri, 15 Feb 2008, schreef Skybuck Flying:

> To me it seems like some kind of trick, to extend a record at runtime.
> The empty record field, functions as a sort of offset/label/pointer if you
> will to the new fields that will will be extended to the record by simply
> allocating more memory then the size of the record.
> Then this "label"/"field" can be used as a sort of offset, by typecasting 
> it
> to some extension record type.
> Could be pretty handy, quite impressive trick.
> However, is it safe to use ?

Empty records are valid Pascal.

> I cannot find anything in the documentation about this ?

Nothing in the documentation says it is forbidden either. The reason
it is not explicetely mentioned is because there exists a
much better method, objects:

type  base_structure=object




> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal 

More information about the fpc-pascal mailing list