[fpc-pascal] Empty record inside another record ?

Skybuck Flying skybuck2000 at hotmail.com
Fri Feb 22 21:19:10 CET 2008

There is another great limitation of your suggested solution.

The offsets for the objects are bound at compile time.

While the record solution allows the offsets to be determined at run time.

Making the record solution a more flexible solution.

In other words objects need to specify their ancestor at compile time 
creating the inflexibility.

The make things even worse. For every possibility a new object declaration 
would be needed and finally it would be an unacceptable solution because 
this would probably add runtime type information to the objects thereby 
adding unwanted fields.

However there might be a different solution which might still be 

1. Non-inherited objects.

2. Maybe empty objects ?

I shall investigate those later on.


----- 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