Xref: utzoo comp.object:1422 comp.lang.eiffel:994 Path: utzoo!attcan!uunet!mcsun!ukc!pyrltd!tetrauk!rick From: rick@tetrauk.UUCP (Rick Jones) Newsgroups: comp.object,comp.lang.eiffel Subject: Re: Should a constructor do "work"? Message-ID: <519@tetrauk.UUCP> Date: 9 Jul 90 10:45:53 GMT References: <55236@microsoft.UUCP> <181@dumbcat.sf.ca.us> <359@eiffel.UUCP> Reply-To: rick@tetrauk.UUCP (Rick Jones) Followup-To: comp.object Organization: Tetra Ltd., Maidenhead, UK Lines: 24 In article <359@eiffel.UUCP> bertrand@eiffel.UUCP (Bertrand Meyer) writes: > > ... > > The purpose of having creation operations (constructors) in a class >is to make sure that every object will satisfy its class's invariant at >creation time. This is a formal requirement in Eiffel (Create must >ensure not only its postcondition, if any, but also the invariant). > A question I would like to ask (of anyone, Bertrand especially) is how should the language or the program design cope with a situation where an object is created, but its create routine ("constructor") is unable to satisfy the invariant due to some run-time condition which the program must trap in a non-fatal way. In Eiffel an exception could be raised, and caught somewhere else, but that would not in itself prevent the existence of the invalid object. The underlying question is whether a constructor should be allowed, under exception conditions, not to create any object and leave the corresponding reference void. -- Rick Jones You gotta stand for something Tetra Ltd. Maidenhead, Berks Or you'll fall for anything rick@tetrauk.uucp (...!ukc!tetrauk.uucp!rick) - John Cougar Mellencamp