comp.lang.ada
 help / color / mirror / Atom feed
From: firth@sei.cmu.edu (Robert Firth)
Subject: Re: Procedure types and dynamic binding
Date: 12 Jan 89 13:57:07 GMT	[thread overview]
Message-ID: <8178@aw.sei.cmu.edu> (raw)
In-Reply-To: 4071@hubcap.UUCP

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.

  reply	other threads:[~1989-01-12 13:57 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-12-30 21:42 Procedure types and dynamic binding Erland Sommarskog
1988-12-31 17:46 ` Bob Hathaway
1989-01-05 10:02   ` William Thomas Wolfe,2847,
1989-01-07 18:05     ` Bob Hathaway
1989-01-07 21:21       ` William Thomas Wolfe,2847,
1989-01-08  1:49         ` Bob Hathaway
1989-01-08 19:01           ` William Thomas Wolfe,2847,
1989-01-08 23:10             ` Bob Hathaway
1989-01-09  1:47               ` William Thomas Wolfe,2847,
1989-01-09 20:19                 ` Bob Hathaway
1989-01-10  3:01                   ` William Thomas Wolfe,2847,
1989-01-10  3:06                   ` Bob Hathaway
1989-01-10 19:11                     ` William Thomas Wolfe,2847,
1989-01-11  2:08                       ` Bob Hathaway
1989-01-11 14:24                         ` William Thomas Wolfe,2847,
1989-01-11 17:51                           ` Barry Margolin
1989-01-11 22:54                             ` William Thomas Wolfe,2847,
1989-01-12 13:57                               ` Robert Firth [this message]
1989-01-12 19:09                                 ` William Thomas Wolfe,2847,
1989-01-14  0:46                                 ` Scott Moody
1989-01-15 18:28                                   ` William Thomas Wolfe,2847,
1989-01-24  4:07                                   ` Paul Stachour
1989-01-12  0:58                             ` William Thomas Wolfe,2847,
1989-01-12  6:12                               ` Barry Margolin
1989-01-11 14:48                         ` Submitting Ada 9X revision requests William Thomas Wolfe,2847,
1989-01-11  2:10                       ` Procedure types and dynamic binding Bob Hathaway
1989-01-05  7:38 ` William Thomas Wolfe,2847,
  -- strict thread matches above, loose matches on Subject: below --
1989-01-06 23:04 Erland Sommarskog
1989-01-07 22:20 ` William Thomas Wolfe,2847,
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox