Path: utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!jos@cs.vu.nl From: jos@cs.vu.nl (Jos Warmer) Newsgroups: comp.lang.eiffel Subject: Re: global objects Message-ID: <5643@star.cs.vu.nl> Date: 22 Feb 90 11:06:14 GMT References: <925@tuewsd.lso.win.tue.nl> <3477@tukki.jyu.fi> <938@tuewsd.lso.win.tue.nl> Sender: news@cs.vu.nl Organization: Fac. Wiskunde & Informatica, VU, Amsterdam Lines: 43 wsttss@lso.win.tue.nl (Steven van der Smagt) writes: >In article <3477@tukki.jyu.fi> sakkinen@jytko.jyu.fi (Markku Sakkinen) writes: >>>Can anyone help us out? Are such global object possible in Eiffel? >Gary Wright proposed an 'elegant' solution to inherit from a class Global: >>Create a class that contains only once functions (let's call the class GLOBAL). >Using the once mechanism to obtain shared objects, depends on >the knowledge how Eiffel is implemented. Eiffel creates >multiple instances of attributes, but only one >(shared) instance of the methods. This has nothing to do with the implementation, but everything with the definition of Eiffel. (Of course, the definition has to be implemented |-:) ) A once function is not just a method. If it was, the Result would be created each time the method was called. This is not what is intended. Gary is right, once functions are THE way to create shared objects. See OOSC for more details. >This confusion arises >because of the 'natural' side effects of methods on the >attributes of the object: you do not specify the attributes of >an object as a parameter when you call a method. >Isn't more logical to use the following syntax: > method(object.attribute) >instead of > object.method Why? A method is called on an object, not on an attribute of an object. Jos Warmer jos@cs.vu.nl ...uunet!mcvax!cs.vu.nl!jos -- Jos Warmer jos@cs.vu.nl ...uunet!mcvax!cs.vu.nl!jos