2018-04-13 5:02 GMT+02:00 Ryan Joseph <[email protected]>:
> Why can’t we just do something simple like this? A simple meta programming
> hack to dump the “default” section at the start of the scope the variable
> is declared in so we don’t have to do this ourselves every time. It
> probably breaks down for init’ing records but for compiler types it seems
> pretty simple.
>
No need for something like new default section. You can just use :
===code begin===
{$MACRO ON}
{$DEFINE TMyRecord_Default := (i: 1; s: 'foo')}
type
TMyRecord = record
i: integer;
s: string;
end;
var
myRec: TMyRecord = TMyRecord_Default;
===code end===
you can also try new management operator "Initialize":
http://wiki.freepascal.org/management_operators
--
Best regards,
Maciej Izak
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal