[fpc-pascal] Record Composition

Ondrej Pokorny lazarus at kluug.net
Fri Oct 23 21:17:02 CEST 2026


On 10/22/2026 8:24 PM, Michael Van Canneyt via fpc-pascal wrote:
> 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.

I guess you can help yourself with a record helper:

TWhateverRecordHelper = record helper for TWhateverRecord
public
   class function Create: TWhateverRecord; static;
end;

Ondrej



More information about the fpc-pascal mailing list