Re: [fpc-pascal] Variable Initialization Questions

2016-02-22 Thread Klaus Hartnegg
Am 18.02.2016 um 21:38 schrieb Jonas Maebe: all global variables are always zeroed. but it is better to not rely on it because Local variables are never zeroed and it is not uncommon that a part from main gets moved to a procedure, and all of a sudden you must add commands to initialize

Re: [fpc-pascal] Variable Initialization Questions

2016-02-21 Thread Mazola Winstrol
2016-02-18 18:38 GMT-02:00 Jonas Maebe : > Mazola Winstrol wrote: > >> Just to clarify: if i have a record type with a pointer field, this >> field will always zeroed? >> > > No. As mentioned, all global variables are always zeroed. The type doesn't > matter. Local

Re: [fpc-pascal] Variable Initialization Questions

2016-02-18 Thread Jonas Maebe
Mazola Winstrol wrote: Just to clarify: if i have a record type with a pointer field, this field will always zeroed? No. As mentioned, all global variables are always zeroed. The type doesn't matter. Local variables are never zeroed, except if they are managed types. A pointer is not a

Re: [fpc-pascal] Variable Initialization Questions

2016-02-18 Thread Mazola Winstrol
2016-02-17 15:16 GMT-02:00 Jonas Maebe : > Jonas Maebe wrote: > >> 3 - When i declare a pointer as a global variable or as a member of a >>> record, can i assume that its initial value is nil? >>> >> >> No. >> > > Correction: all global variables are always zeroed, so

Re: [fpc-pascal] Variable Initialization Questions

2016-02-17 Thread Jonas Maebe
Jonas Maebe wrote: 3 - When i declare a pointer as a global variable or as a member of a record, can i assume that its initial value is nil? No. Correction: all global variables are always zeroed, so that includes pointers, records and hence also pointers in records (if those records

Re: [fpc-pascal] Variable Initialization Questions

2016-02-17 Thread Jonas Maebe
Mazola Winstrol wrote: 1 - Does the compiler automatically initialize all class fields when a new instance is created? They're called instance fields, and yes, they are zeroed. Class fields are fields that that are unique per class type, rather than per instance. 2 - Does the compiler

[fpc-pascal] Variable Initialization Questions

2016-02-17 Thread Mazola Winstrol
Hello List, After googled and searching in the documentation, http://free-pascal-general.1045716.n5.nabble.com/does-Advanced-Record-constructor-automatically-zero-all-the-memory-space-of-that-record-td5716755.html http://www.freepascal.org/docs-html/ref/refse23.html i still have doubts about