afscian@violet.waterloo.edu (Anthony Scian) (07/28/89)
During my reading of OOSC, I have noticed some problems with Eiffel. One problem has to do with initialization of object data items. For instance, it is not possible to use a declaration like this: cutoff : COMPLEX is (2,0); Now, in 13.3 Constants of class types, this problem is skated around with an example of the special complex constant, 'i'. The initialization is not done at link-time but at run-time. The problem is apparently solved with a once function but this requires that all initializations occur at run-time. The constant 'i' cannot be used to initialize an array of COMPLEX numbers, how does this solve the problem of constants of class types? The same deficiency occurs in the APPLICATION object description because it is not possible to have the STATE arrays and transition matrices initialized with constant expressions. This results in a waste of memory for the initialization of arrays. The memory occupied by the init code is wasted once the initilization has occured. Initialization of arrays (say, for a parser) would amount to roughly twice the amount of memory necessary being used. (each INTEGER constant in the parser table is in the code and in the table) The problems of satisfying class invariants with true constant initialization are significant. Currently, Eiffel is consistent and safe, but for environments that have memory restrictions (and cannot afford waste) a form of constant initialization would be useful in some applications. The problem can be avoided with initialization of data structures from files, but this is fraught with pitfalls of its own. Of course, the goals behind the language design must be maintained even if a (possibly) small set of applications do not benefit from these goals. The attitude in the chapter mentioned is that constants for class types are a bad thing rather than detailing different methods with tradeoffs. (ie. the C++ method of hiding the run-time initialization) Anthony //// Anthony Scian afscian@violet.uwaterloo.ca afscian@violet.waterloo.edu //// "I can't believe the news today, I can't close my eyes and make it go away" -U2