Re: [fpc-pascal] how to use Default to replace this ' FillChar(aRecord, sizeof(aRecord), 0);

2016-12-07 Thread Sven Barth
Am 08.12.2016 05:14 schrieb "Lars" : > > On Mon, December 5, 2016 4:46 am, Dennis Poon wrote: > > > > > > > Lars wrote: > > > >> Do you know about this feature: > >> > >> > >> var SomeRec: TSomeRecord = (); > >> > > This is good for global variable. > > But I wonder whether it

Re: [fpc-pascal] how to use Default to replace this ' FillChar(aRecord, sizeof(aRecord), 0);

2016-12-07 Thread Lars
On Mon, December 5, 2016 4:46 am, Dennis Poon wrote: > > > Lars wrote: > >> Do you know about this feature: >> >> >> var SomeRec: TSomeRecord = (); >> > This is good for global variable. > But I wonder whether it has effect in procedure's local variable since > it requires the compiler to clear

Re: [fpc-pascal] how to use Default to replace this ' FillChar(aRecord, sizeof(aRecord), 0);

2016-12-05 Thread Dennis Poon
Lars wrote: Do you know about this feature: var SomeRec: TSomeRecord = (); This is good for global variable. But I wonder whether it has effect in procedure's local variable since it requires the compiler to clear the record on the stack (which is at different location every time).

Re: [fpc-pascal] how to use Default to replace this " FillChar(aRecord, sizeof(aRecord), 0);

2016-12-05 Thread Dennis Poon
Sven Barth wrote: Am 05.12.2016 08:24 schrieb "Dennis" >: > > In this old statement, I don't need to know the type of aRecord > but if I want to use Default, I have to know the exact type of the varaible aRecord and pass it to

Re: [fpc-pascal] how to use Default to replace this " FillChar(aRecord, sizeof(aRecord), 0);

2016-12-05 Thread Sven Barth
Am 05.12.2016 08:24 schrieb "Dennis" : > > In this old statement, I don't need to know the type of aRecord > but if I want to use Default, I have to know the exact type of the varaible aRecord and pass it to Default(aRecordType) e.g. aRecord := Default(aRecordType) //where

Re: [fpc-pascal] how to use Default to replace this ' FillChar(aRecord, sizeof(aRecord), 0);

2016-12-05 Thread Lars
Do you know about this feature: var SomeRec: TSomeRecord = (); This initializes the record without needing fillchar. I assume your "Default()" call initializes the record initially. You can eliminate the default() call by initializing the record as part of your declaration. Some criticize

[fpc-pascal] how to use Default to replace this " FillChar(aRecord, sizeof(aRecord), 0);

2016-12-04 Thread Dennis
In this old statement, I don't need to know the type of aRecord but if I want to use Default, I have to know the exact type of the varaible aRecord and pass it to Default(aRecordType) e.g. aRecord := Default(aRecordType) //where var aRecord : aRecordType Is it possible to use default