[fpc-pascal] Default record fields

Ryan Joseph ryan at thealchemistguild.com
Sat Jun 23 05:25:44 CEST 2018



> On Jun 23, 2018, at 3:15 AM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> More often than not people use classes instead of records and even then for records constructors (or factory methods) cover the important cases. E.g. for TPoint there is Point() while 3.0.0 also added TPoint.Create() and a TPoint.Zero() as convenience method for an empty TPoint.

Sure, and those are all welcome additions to the language which I use often.

I’m speaking of the general friction when creating custom records and having to go through the boiler plate of adding those methods every time and breaking the record into the implementation so I can have class functions (which need to be called also) or now initialize operators which save the calling step. It’s just friction in the development process and busy work.

My thinking was that because variables can assign values at declaration it would be reasonable to assume that record fields could have default values which would be assigned at declaration. It sounds like a natural extension of the syntax that already exists.

I assumed (wrongly perhaps) because this feature exists in c++, c#, swift etc… that it was in demand.

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list