On Fri, 2009-06-19 at 18:35 +0200, Jürgen Hestermann wrote: > > The "var" version, acts as if your first statement in the procedure was > > "a:= 1;". It initializes the variable each time you enter the function. > > If you enter the function recursively, then each level, has it's own a, > > not touching the value of the callers a > > I also used Borlands "const-hack" a lot. But now I changed my behaviour > and use VAR declarations directly before the function declaration (one > level higher, outside the function context). That serves the same purpose.
The writeable const hack is slightly different in that the scope of the inconstant constant is local to the function, whereas moving it to a var at global scope makes it visible to all functions within the unit. This issue has been a criticism of the Pascal language dating back to the days of Jensen and Wirth. In ALGOL 60, variables with static duration were declared as "own", which made no sense in English terms; worse still, ALGOL 60 had no initializers at all, so these variables could not be initialized at program load time. In contrast, PL/I used the attribute STATIC, which described the semantics concisely, and permitted an INIT() option to set an initial value. [In those days, both FORTRAN and COBOL used static duration with no option available to alter it. Yuck!] I think it is more expressive to make the semantics clear by declaring an inconstant constant as a variable -- because that's what it is -- with a duration modifier to show that it has static duration. I suppose that for symmetry there should be an antonym, automatic, which is accepted by the compiler but produces the current, default semantics. -- Regards, Dave [RLU #314465] ======================================================================= david.w.n...@ntlworld.com (David W Noon) ======================================================================= _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal