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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,99ab4bb580fc34cd X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Q: access to subprogram Date: 1996/07/06 Message-ID: #1/1 X-Deja-AN: 164067597 references: <4rb9dp$qe6@news1.delphi.com> <4re2ng$t7u@wdl1.wdl.loral.com> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-07-06T00:00:00+00:00 List-Id: In article , Jon S Anthony wrote: >I can maybe buy the second bit (about difficulty for display based >impls) but the first makes no sense. You wouldn't have to pass >displays or whatever in those cases where the feature wasn't being >used. Which means that there is _no_ distributed overhead for the >99+% of regular ol' subprogram calls. I posted a note in this thread saying the same thing. But, having read Robert Dewar's posts, I have to admit that the "distributed overhead" argument is not totally off the wall. The argument is: 1. Displays are too much trouble, in the presence of downward closures. (Or, are they upward closures? You know what I mean -- passing procedures as parameters.) 2. Therefore, if we have that feature, compiler writers are forced to use static links (or are at least sorely tempted to use static links -- it makes things simpler, and as Robert pointed out, the simplicity-vs-complexity we're talking about is towards the back end of the compiler, which is the hardest part to debug, and may be duplicated for numerous kinds of hardware). 3. Displays are clearly faster than static links, for normal direct calls. 4. Therefore, we've got a distributed overhead; QED. This argument makes *some* sense, but I dispute point 3. I'm not really sure, but I think that perhaps static links are faster. I'm quite *sure* of two things: it doesn't make much difference, since most code isn't very deeply nested anyway, and if there *is* a difference, it's not a big difference. Of course, one might wish for some scientific experiment that could tell us once and for all which is better. Unfortunately, I don't think it's that easy. For one thing, you have to write the same compiler both ways, which is expensive. For another, the issue is affected by other optimizations -- for example, a static link implementation will be much better if the compiler is smart enough to do CSE elimination on loads of the static link, or chains therefrom. But a display implementation won't care so much about that particular optimization. For another thing, it depends on the sort of programs you write. Most Ada code I've seen has very few procedures-within-procedures, which is where the difference counts. And five-level nested procedures are very uncommon, I suspect. But some people like to nest more than others. ;-) - Bob