Search code examples
integercomponent-pascal

Initialize variables in the Component Pascal by default


Integer type variables are initialized by default in a strange way.
Look at this code:

MODULE MyTest;
    IMPORT Log;
    PROCEDURE Start*;
    VAR a, b, c, d: INTEGER; (* This variables *) 
    BEGIN
        Log.Int(a);
        Log.Ln;
        Log.Int(b);
        Log.Ln;
        Log.Int(c);
        Log.Ln;
        Log.Int(d);
        Log.Ln;
    END Start;
END MyTest

Here is the result:

4233640
2287340
2287344
576

Thanks!


Solution

  • Like most Wirthian languages, probably variables(and specially local ones) are probably uninitialized. They may be initialized by chance, but usually there is no guarantee.