It's not really a problem so far it seems.

Simply replace record with object and it will work and compile at least in Delphi.

I haven't tried FPC yet... but if it wouldn't compile that would be amazing and a problem.

None the less, the example remains interesting.

It describes a general problem:

How to switch between data structures/layouts and still use more or less the same code, could be different code underwater, for the programmer it must look the same.

The example does just that. It always the programmer to work with 64 bit integers, and finally it can write them and read them as any other kind of integer or data structure.

So concept is:

1. Work internally with 64 bit integers.

2. Use bitmode to switch to something else on reading and writing.

Might give the programmers of free pascal maybe an idea for the future for some kind of language extension lol.

I am not counting on it... but who knows :)

I shall give a little example to give a better idea:

Tstructure1 = record
   blablabla
end;

Tstructure2 =
   bla
   blablabla
   bla
end;

TstructureType = ( Tstructure1, Tstructure2 )

var
   SomeVariable : TstructureType;
   SomeStructure : SomeStructure?;

begin
   somevariable := Tstructure1;

   select somestructure based on somevariable do
   begin
       blablabla := 464; // structure1.blablabla
   end;
end;

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

Reply via email to