[fpc-pascal] Record Composition
Michael Van Canneyt
michael at freepascal.org
Thu Oct 22 20:24:40 CEST 2026
On Thu, 22 Oct 2026, Thomas Kurz via fpc-pascal wrote:
> I'm trying to use this feature, but I'm having some trouble:
>
> All of my records contain a parameterless `class function Create: TWhateverRecord; static;`.
>
> Now, when I try to contain one within the other, I'm stumbling across this compiler error:
>
> Error: Overloaded identifier "CREATE" isn't a function
>
> I guess this is because both records now have a `Create` function with the same signature. But how can I resolve that conflict?
You cannot, it is a shortcoming of composed records. There is no way to
distinguish between the various methods. Although the message needs
improvement.
> And one more question: Does `Default(TComposedRecord)` correctly intialize the complete structure?
Basically it does a fillchar(var,sizeOf(TComposedRecord),0), so that should be
sufficient.
Michael.
More information about the fpc-pascal
mailing list