Re: Problem upgrading c4gl to 7.20 (variable initialisation)
Posted in 1998
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
In article <70ip88$b8r$1@news.xmission.com>, Jonathan Leffler <jleffler@informix.com> wrote: > >On Tue, 20 Oct 1998, Peter Lancashire wrote: > >> Jonathan Leffler wrote: >> > [...] Otherwise, uninitialized local >> > variables have whatever random garbage was left over from whatever >> > previously used the same space. [...] >> > >> > I sometimes think we should have introduced a scheme whereby >> > random values were copied into local variables deliberately to ensure that >> > they were initialized correctly by the user, especially in p-code where the >> > variables are actually set on entry to the function (which leads to the >> > biggest problems when code is ported from p-code to c-code). >> >> Might another solution have been to change the language to force the >> programmer to initialise the variable when defining it? > >Force wasn't an option -- backwards compatability. > >Some systems (notably SunOS/Solaris) seem to bend over backwards to zero >previously unused stack. Since there's a function call at the start of >each I4GL function now (that helps eliminate the TSS overflow and error >-4518), that function now scribbles over the previously clean stack, >leading to bigger problems. This misguided zeroing on Solaris has caused >endless problems, even within Informix when code that seemed to work on >Solaris didn't work on other machines. The Sun environment is too damn >friendly sometimes. There's an interesting discussion on some other news >group (maybe comp.software.config-mgmt) about giving the developers the >older, less capable machines so that what works fast enough for them will >work even better on the actual users more recent, more powerful machines. >I have at least some sympathy for that viewpoint. > >> It seems a little kinder to me. >> Syntax might go: >> >> DEFINE myvar smallint = 4 >> >> or, kinder to the user but less so to the compiler writer: >> >> DEFINE myvar = 4 smallint > >That would be a possibility. > >> Perhaps the type name first as in C has some merit? ;-) > >Yes. All sorts of things might be possible. But the basic problem >of uninitialized variables is the same -- the value is not reliably >predictable, even though it may have seemed to be predictable with >some previous version of the o/s, C compiler or I4GL compiler. > Another option would be a switch on the 4GL compiler to do the sort of unitialized variable checking that is done by lint, gcc etc. Give the users the option to output warnings and allow users to do what they want with them (such as ignore them...). Robert