[fpc-pascal] Record operator for assignment
Ryan Joseph
ryan at thealchemistguild.com
Fri Apr 28 07:33:34 CEST 2017
> On Apr 28, 2017, at 12:21 PM, LacaK <lacak at zoznam.sk> wrote:
>
> you can workaround this by using typed constant for instance. Something like:
>
> const
> DEFAULT_REC: TMyRec = (x: 0; y: 0; z: 0 );
> var
> rec: TMyRec;
> begin
> rec := DEFAULT_REC; // or rec := Default(TMyRec) if you want zeroes
> ...
>
> L.
Run time is the problem though. If the compiler knows how to define a record using that syntax you should be able to do
rec := (x: a; y: b; z: c);
instead of mucking around with constructors which do basically the same thing but with boiler plate code. The syntax for a default constructor already exists in the language but it’s not implemented outside of type declarations for some reason.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list