Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General Discussion » View Thread |
Messages 11 to 12 of 12 total |
Weird problem |
Thu, Apr 15 2010 2:32 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Lance
>By default with Delphi 7 and up from what I've seen is the default value of a boolean is false. Interesting. I'm still struggling to get my head round this one. Declare a boolean and it points at a random bit of memory. If that chunk of memory had been used before the probability is that its non-zero so either a boolean is: true if non-zero, false if zero or true if none, false if not one or it has an indeterminate state or its initialised. I think I'll post this on the cg ngs for a definitive answer. >Jud Cole, from Sock Software (CodeHealer), was in Seattle doing a presentation at our Delphi Users Group. He did a part session on some "good habit coding", and pointed out that it's good practice to manually initialize variables to insure you get what you think. Also to have the results of any function call be assigned to a variable, even if you're not using them, to insure keeping down memory leaks and such. > >Drawback is you get warnings sometimes pertaining to these as the compiler doesn't grasp the big picture in that while you know you don't need it, you are insuring the values is set how you want. I know that one Roy Lambert |
Thu, Apr 15 2010 9:21 AM | Permanent Link |
Raul Team Elevate | Roy,
This is what it should do (see http://docwiki.embarcadero.com/RADStudio/en/Variables and local help has it under variables): "If you don't explicitly initialize a global variable, the compiler initializes it to 0. Object instance data (fields) are also initialized to 0. On the Wiin32 platform, the contents of a local variable are undefined until a value is assigned to them. On the .NET platform, the CLR initializes all variables, including local variables, to 0. " Raul |
« Previous Page | Page 2 of 2 | |
Jump to Page: 1 2 |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |