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.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!lll-winken!lll-ncis!helios.ee.lbl.gov!nosc!ucsd!rutgers!rochester!pt.cs.cmu.edu!sei!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.lang.ada Subject: Re: Procedure types and dynamic binding Message-ID: <8178@aw.sei.cmu.edu> Date: 12 Jan 89 13:57:07 GMT References: <35339@think.UUCP> <4071@hubcap.UUCP> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu (Robert Firth) Organization: Carnegie-Mellon University, SEI, Pgh, Pa List-Id: In article <4071@hubcap.UUCP> billwolf@hubcap.clemson.edu writes: > I haven't done an extended investigation of the literature, but > procedural variables in Algol-family languages would appear to > be a research topic I hardly think so. Procedure variables have been around for over 20 years, and the implementation issues are pretty well understood. As for Algol, when I had to write an Algol-60 compiler in the late '70s, the only "research" required was reading the literature from the early '60s that told me how to do it. My most valued source was the early volumes of "Annual Reviews in Automatic Programming", supplemented by Hopgood's old monograph "Compiler Construction". There is just one problem with procxedure variables that has not quite been completely solved. It is illustrated by this: type proc_type is procedure; procvar : proc_type; procedure outer is X : integer; procedure inner; begin X := X+1; end; begin procvar := inner; end; outer; procvar; The final statement invokes the value of procvar, which is, of course, "inner". The call of inner references the variable X declared in outer, which no longer exists. This is the equivalent of the "dangling reference" problem when the address of a local variable is assigned to a global pointer. Many solutions have been proposed; the cleanest in my opinion is that of Modula-2, which does not allow an "inner" procedure to be assigned to a variable. If that were combined with reasonable visibility rules (so that a procedure could be unnested without perforce being made visible), I think it would be a definitive solution.