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: f43e6,2c6139ce13be9980 X-Google-Attributes: gidf43e6,public X-Google-Thread: fac41,2c6139ce13be9980 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,3d3f20d31be1c33a X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,2c6139ce13be9980 X-Google-Attributes: gid1108a1,public From: Nick Leaton Subject: Re: Interface/Implementation (was Re: Design by Contract) Date: 1997/09/10 Message-ID: <3416629B.171A4BBE@calfp.co.uk>#1/1 X-Deja-AN: 271230323 X-NNTP-Posting-Host: calfp.demon.co.uk [158.152.70.168] References: <340C85CE.6F42@link.com> <3414BF1E.2E7C@ac3i.dseg.ti.com> <34151769.6343E724@calfp.co.uk> <3415E780.4A53@ac3i.dseg.ti.com> Reply-To: nickle@pauillac Newsgroups: comp.object,comp.software-eng,comp.lang.ada,comp.lang.eiffel Date: 1997-09-10T00:00:00+00:00 List-Id: John G. Volan wrote: > 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. That isn't the only way to implement it. As the reference is void initialy, you could trap the attempt to access, then call the creation. The interupt is relatively cheap, particularly as it is a once per exectution. Subsequent accesses are as fast as always. > 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. Does this mean that all global objects are initialised? If so compare that with just in time creation. If you don't use a global, it isn't created. You cannot tell which globals you will need at compile time, just which one may be needed. Now if you have a global that takes a long time to create, reference it at the start, and you get the psycologically better situation of a longer start up time, traded off for no long pauses once you are running. This would also be important in real time systems. > > 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!" :-) > Actually it comes from a lager advertisment. Heiniken, where it was the slogan. -- Nick Eiffel - Possibly the best language in the world - unless proven otherwise.