Is it possible to implement "absolute" keyword from Pascal?
Or maybe there is something already implemented with this functionality?
A very convenient thing I use everyday while programming in fpc/Lazarus.
var a:integer; var b:array[0..3] of byte absolute a; var c:integer absolute $deadbeef;
In Basic syntax it may look like this:
dim a as integer dim b(4) as ubyte absolute a dim c as integer absolute $deadbeef
In FreePascal this places the variable b at the same place in the memory as variable a. Variable c is placed in the memory at the address $deadbeef
What can it be used for? The first syntax gives automatic type conversion. I write this here and now because I have now this problem - send and receive bytes from serial while the data are longs. Two arrays, one for bytes, one for longs, placed at the same place does this automatically without any complex messing with pointers and conversions.
The second syntax is very convenient if you need to use hardware registers. The P2 doesn't need it as it has all of its registers already defined, but I use this while bare metal programming the RPi.