wgh@ubbpc.UUCP (William G. Hutchison) (10/19/90)
As Bertrand Meyer has wittily pointed out, Eiffel supports exceptions and generic types now, whereas C++ implementations will support them sometime later in this millenium. I would prefer to stick to C++ because it is available from multiple sources, whereas only Messrs. Meyer et Cie. seem to have the wherewithal to sell and support Eiffel. G++ may soon have exceptions and generics (as templates, not macros), but I would prefer not to mess with copyleft systems when preparing commercial products. So what is one to do waiting for the Utopia99++ compiler which will support all these nicenesses? It seems that one should use techniques now that do not preclude upgrading to exceptions and templates in the future. What are those techniques? For now, I am using an ad hoc, empirical approach: I am using error_handlers sort of like those in libg. It is an interesting design issue whether the error_handler for a class should be static (global for the whole class), or local for each object (more flexible but more overhead). Some kinds of classes seem to need the latter approach: for example, a class wrapper for Informix C-ISAM: when I am adding a new index to a file, I might just want to log the error and exit if it fails, but if I am reading an index of another file which allows duplicate values, I might want to examine the error code of that file to determine if I got the EOF (rather than calling abort() [!]). The point is that both behaviors might be required by different files in the same program, so repeatedly switching error_handlers back and forth, if there was a single, global one, would be awkward. For generics, I am using the approach of making each class inherit from public virtual Item, a class which does nothing but provide commonality so that a container class can hold anything as an Item*. (This technique was suggested by Bruce Eckel). What other approaches are recommended? -- Bill Hutchison, DP Consultant rutgers!cbmvax!burdvax!ubbpc!wgh (work) Unisys UNIX Portation Center uunet!eidolon!wgh (home) P.O. Box 500, M.S. B121 "At the moment I feel more like arguing than Blue Bell, PA 19424 being good" Raymond Smullyan _The Tao is Silent_