[fpc-pascal] Re: classes initialization
L
L at z505.com
Wed Mar 26 00:50:27 CET 2008
> Pascal does not define any variable initialization itself - one should
> always init all Pascal vars of any type. Doing so is an excellent
coding > habit also portable to any other language/OS - protects against
> low-level implementation changes.
>
> I never trust a side effect I didn't code myself..... 8-))
We have to stop thinking in standard pascal and think about safety and
ways to automate safety in a human matter. We are not computers, we are
humans. You can claim all you want that you will ALWAYS init all your
pascal vars... but you are a human and you will not *always* init all
your pascal vars. This is the reason features like this have been available:
var i: integer = 0; // handy
procedure test;
var i: integer = 0; // handy
begin
end;
If you accidentally delete the init code and forget to put it back, the
above way is safer. If you accidently init something in a dangerous way
such as using FillChar on old code that now no longer works with the
newer automated types.. again this is dangerous. It may be "pascalish"
to continue to use hacks like FillChar and init() code far away from the
declaration (especially in globals).. but this is the same as a C
programmer saying that ansistrings are not C ish so we should use pchars
all the time?
Let's please stop the pascal fanboyism and consider humans, and safety.
Even Wirth has moved away from pascal greatly if you study his languages
Oberon, Modula, and a derived ComponentPascal.
L505
More information about the fpc-pascal
mailing list