From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,2c6139ce13be9980 X-Google-Attributes: gidfac41,public X-Google-Thread: 1108a1,2c6139ce13be9980 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,3d3f20d31be1c33a X-Google-Attributes: gid103376,public X-Google-Thread: f43e6,2c6139ce13be9980 X-Google-Attributes: gidf43e6,public From: "John G. Volan" Subject: Re: Interface/Implementation (was Re: Design by Contract) Date: 1997/09/09 Message-ID: <3415E780.4A53@ac3i.dseg.ti.com>#1/1 X-Deja-AN: 271111273 References: <340C85CE.6F42@link.com> <3414BF1E.2E7C@ac3i.dseg.ti.com> <34151769.6343E724@calfp.co.uk> Reply-To: johnv@ac3i.dseg.ti.com Organization: Raytheon TI Systems Newsgroups: comp.object,comp.software-eng,comp.lang.ada,comp.lang.eiffel Date: 1997-09-09T00:00:00+00:00 List-Id: Nick Leaton wrote: > > x: MY_CLASS is > once > !!Result > end > > The first time I use x, Result will be made. The second time I use x, > the Result from the previous use will be returned. Think of it as a just > in time singleton. Suppose such a "once" function is referenced at several different points in a program. If the compiler were able to predict which of these references would be the first to occur at runtime, then perhaps it would be able to perform some optimizations: It could inline the object-creation code right at the first call, and then turn all the subsequent calls into direct object references. But I don't think it's possible, in principle, for a compiler to make such a prediction. (My guess is that it's equivalent to the halting problem.) So it seems to me that every reference to a "once" function would have to incur the overhead of a functional call, plus a conditional test to determine whether the object has already been created "once" before. Sounds like a pretty heavy-weight way to implement global objects. Contrast this with Ada's scheme: The compiler treats a reference to a global object the same way it treats any other kind of object reference, with no extra overhead inserted into the generated code. But because of Ada's elaboration-order rules, any such reference is guaranteed (more or less) to occur after the elaboration of the object. > Eiffel - Possibly the best language in the world - unless proven > otherwise. Hmm. To paraphrase -- who was it? Winston Churchill? -- perhaps you should say "Eiffel is the worst language on Earth ... except for all the others!" :-) -- ------------------------------------------------------------------------ Internet.Usenet.Put_Signature (Name => "John G. Volan", Employer => "Raytheon/TI Advanced C3I Systems, San Jose, CA", Work_Email => "jvolan@ti.com", Home_Email => "johnvolan@sprintmail.com", Slogan => "Ada95: World's *FIRST* International-Standard OOPL", Disclaimer => "My employer never defined these opinions, so using " & "them would be totally erroneous...or is that just " & "nondeterministic behavior now? :-) "); ------------------------------------------------------------------------