Indeed better rely on one of the core developers to provide a more clear answer.
Exactly.
Even if things look like something it is not guaranteed to be the same in the (near) future).
I doubt their memory layout will change in the future. It probably hasn't changed since they were introduced in the language. But even if it did, I can still use the previous compiler version (i.e. 3.2.2) for another 10-20 years, as long as it produces correct executables for the given platform.
I eventually solved that by using a managed record that contained a class (it was the quickest (and dirtiest) solution at the time).
The simplest way to implement inheritance in currently supported records (even simple ones) is to declare a field with the same type as the base type:
type
TParent = record
// fields
end;
type
TChild = record
Parent: TParent;
// fields
end;
Considering that in practice these two records would be declared in separate units, there are two problems that I want to avoid:
- The contents of structures (at least in all parent record types) must be public.
- Fields of the parent type must be accessed through the Parent field, which creates a redundant namespace.
Honestly, I could use an additional
Parent namespace to clearly see in the code which variables come from the parent type and which from the inherited type, but the problem is that each new inheritance adds a new
Parent namespace, so with a longer inheritance path, the syntax for accessing the fields of this first parent record would require something like
Parent.Parent.Parent.SomeField, which is absurd. But still the lack of possibility to encapsulate these structures is a hindrance for me.
There would be no problem if advanced records supported
protected sections but they don't.
So, to sum up, I'll stick with TP objects for now because they do the job. However, I will keep in mind that their memory layout is not guaranteed.