[fpc-pascal] compile time init'ing records

Ryan Joseph ryan at thealchemistguild.com
Fri Apr 13 11:54:06 CEST 2018



> On Apr 13, 2018, at 4:27 PM, Maciej Izak <hnb.code at gmail.com> wrote:
> 
> FPC has "Initialize" operator for such purposes :  http://wiki.freepascal.org/management_operators
> 

These are great and one of the best features to be added in a while but that’s not the same. I mean a default constructor like Create() which the compiler automatically generates and takes as parameters the fields of the record. Making the same boiler plate constructors for records all the time is not so great.

var
  rec: TPoint;
begin
  rec := TPoint(x: 100, y: 100);


I mentioned this some time ago since Pascal already has that syntax for init records at compile time. Now that I mention it, you could use the same syntax with no arguments to zero the record.

var
  rec: TPoint = ();
begin

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list