From: billwolf@hubcap.clemson.edu (William Thomas Wolfe,2847,)
Subject: Re: Procedure types and dynamic binding
Date: 12 Jan 89 19:09:12 GMT [thread overview]
Message-ID: <4078@hubcap.UUCP> (raw)
In-Reply-To: 8178@aw.sei.cmu.edu
From article <8178@aw.sei.cmu.edu>, by firth@sei.cmu.edu (Robert Firth):
> 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.
Why not something along the lines of the "restricted" clause present
in Preliminary Ada? Then inner's specification would require that
an integer named X be visible in the environment; the attempt to call
procvar would then result in an error which would be similar to
a "missing parameters" situation. This would have the added benefit
of completing the idea of a specification such that ALL interactions
between a procedure and its environment are fully documented (and
compiler-enforced) in the specification, considerably simplifying
program debugging and maintenance.
Also, since Barry was unable to give an answer, for what situations
would the use of procedural variables be intuitively natural and
necessary? Just some example of a realistic applications program
for which current Ada would prove inadequate, some motivating reason
for wanting to have procedural variables which would justify such
a change.
By the way, would this extend also to packages? Package variables?
Bill Wolfe
wtwolfe@hubcap.clemson.edu
next prev parent reply other threads:[~1989-01-12 19:09 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
1989-01-12 19:09 ` William Thomas Wolfe,2847, [this message]
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