Is there any guaranteed default value for the Result variable of a function, like 0, \'\' or nil? Or should Result always be initialised before use?
<
I don't know what it's like in Delphi, but I always initialize variables to a sane value before I perform operations on them (even if that sane value is null, which it might very well be in some situations). Many times it's unneeded, but in those instances, I count on the compiler or JITter to optimize the assignment out if it wants to, rather than relying on potentially undocumented language semantics or compiler implementation details. Maybe it's my background in C, which in and of itself essentially guarantees nothing about initial values, but it feels worthwhile to spend the extra one line of code (at most) in order to get clearer code. By explicitly assigning a value before you start working on the variable, you establish a clear contract with whoever is reading the code; they can trust that their idea of what the starting value of the variable is, actually holds.
As for this particular question, though; isn't Result supposed to be function-local in scope? I would be very surprised if such a variable, even though special, kept values from previous invocations of the function.