Finally there is another question remaining:

Are objects always packed ?

If not then it could be a problem.

Something which records do allow.

Bye,
 Skybuck.

----- Original Message ----- From: "Daniël Mantione" <[EMAIL PROTECTED]>
To: "FPC-Pascal users discussions" <fpc-pascal@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
        field1:byte;
      end;

      extended_structure=object(base_structure)
        field2:byte;
      end;

Daniël


--------------------------------------------------------------------------------


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

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

Reply via email to