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/03 Message-ID: #1/1 X-Deja-AN: 163548581 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-03T00:00:00+00:00 List-Id: In article <4re2ng$t7u@wdl1.wdl.loral.com>, Mark A Biggar wrote: >If I remember right, it was felt that implementing "closures" (which is the >solution to this problem) placed an unacceptable distributed overhead >on programs that didn't use the feature. Also I think that half the then >current Ada implementations were using "static links" and the other half >were using "displays" and implementing "clousers" would have been real >difficult for one of those groups (the "display" bunch I think). We're only talking about "downward closures", which means you can pass a subprogram (or a pointer to it, which amounts to the same thing) to a subprogram. Nobody ever seriously proposed that Ada should support full closures (as in Lisp), where you can *return* a subprogram from a function. Full closures means you really have to store "stack frames" in the heap, in general, rather than on the stack, and garbage collect them. The part about static links vs. displays is correct, although I don't think it was really 50/50. I think *most* imlementations used static links. It is true that downward closures are harder to implement using displays. It is certainly possible, however. I know of a Pascal compiler that did it. Downward closures are a standard part of Pascal, and this particular Pascal compiler used displays. The issue was not one of distributed overhead, though. Passing displays around may be less efficient, but only in the case where the downward closure feature is actually used. It would have no effect on the efficiency of plain vanilla subprogram calls. The issue was primarily implementation complexity (for those implementations that use displays). The inefficiency issue was raised also (why add a feature if it's going to be so inefficient that noone can use it?). The latter argument always seemed bogus to me. There was never a distributed overhead argument. Oh, and of course, there's the "we don't need it" argument. Passing a subprogram as a generic formal parameter does almost the same thing, though more verbosely, and with a lot of space-inefficiency (unless your implementation knows how to share generics). Generics can't be recursive, though. I remember exactly one instance in my career where I used recursive downward closures (in Pascal). - Bob