Path: utzoo!dciem!nrcaer!sce!cognos!keithc From: keithc@cognos.UUCP (Keith Campbell) Newsgroups: comp.lang.eiffel Subject: Re: Eiffel cleanup #1: The creation mechanism Keywords: Separate operation on references from operations on objects Message-ID: <7862@cognos.UUCP> Date: 18 Jan 90 14:15:29 GMT References: <226@eiffel.UUCP> Reply-To: keithc@cognos.UUCP (Keith Campbell) Organization: Cognos Inc., Ottawa, Canada Lines: 65 In article <226@eiffel.UUCP> bertrand@eiffel.UUCP (Bertrand Meyer) writes: [about plans for version 3] >There is only one creation instruction. Its most general form is > x !D!f(...) >where x is a read-write entity of some type C and D is a descendant of >C; f must be a creation procedure of D. This creates an instance of >D, applies the default initializations, calls f with the actual arguments >given, and attaches the resulting object to x. >D may be omitted in the most frequent case, for which it is the same >as C, giving the form > x !!f(...) >For a class which has no creation procedure (meaning that the default >initializations are sufficient to ensure the invariant), the syntax >becomes simply > x !! In the interest of further reducing useless local variables, I suggest that you go one step further and allow creation of anonymous objects. Thus x !D!f(...) would be equivalent to x := !D!f(...) The improvement is that now we can pass newly created objects as actual parameters without the need for the declaration of local variables: foo( !D!f(...), !E!g(...), ... ); If the compiler is given the ability to infer the (most general) class of object which needs to be created, then x := !!f(...) would be equivalent to x !!f(...) and x := !! would be equivalent to x !! All of us are comfortable with the use of the symbol "1" to mean !Integer!.incremented Why not extend this flexibility to all classes? Note that "incremented" cannot be confused with a creation feature because it appears following the dot ".". In this case, the compiler must generate code to first create this object (using the default initializations) before the "incremented" function may be applied. -- Keith Campbell Cognos Incorporated S-mail: P.O. Box 9707 Voice: (613) 738-1338 x5222 3755 Riverside Drive FAX: (613) 738-0002 Ottawa, Ontario UUCP: uunet!mitel!sce!cognos!keithc CANADA K1G 3Z4