comp.lang.ada
 help / color / mirror / Atom feed
* Procedure variables
@ 1989-01-16 17:17 Dale Worley
  0 siblings, 0 replies; 2+ messages in thread
From: Dale Worley @ 1989-01-16 17:17 UTC (permalink / raw)



   From: firth@sei.cmu.edu  (Robert Firth)
   Subject: Procedure types and dynamic binding

   [discussion of problems that can arise with procedure-valued variables]
   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.

There are two other clean solutions which I know of.  One used by
Algol 68 is that you can't assign a procedure-value to any variable
that would allow it to be exported out of the procedure or block that
created the variables that it refers to.  Of course, in general this
has to be checked at runtime.  But it lets you do most of what you
want to do with procedures with very little overhead (if you disable
the runtime checks!).

The other solution is used by Scheme, and allows the procedure-value
to carry along with it the variables from its environment that are
necessary for its execution.  This requires that the procedure-value
(in general) be represented by more than just a pointer to its code,
but it can be used to implement a number of useful things that can't
be easily expressed in most programming languages.  (For instance,
true object-oriented programming.)  Efficient implementation of this
system requires good global analysis of the program, which has been
done in a few Scheme compilers.

Contrary to popular belief, procedure-valued variables are not "poorly
structured".  They do have the problem that you can't determine
(statically) where control is going, but presumably the procedure is
an encapsulation of some conceptually well-defined operation, and so
you know what it does, even if you don't know what code is doing it.

Dale

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: procedure variables
@ 1991-02-15 10:16 forsyth
  0 siblings, 0 replies; 2+ messages in thread
From: forsyth @ 1991-02-15 10:16 UTC (permalink / raw)


In article <633.27b83c4c@vger.nsu.edu>, g_harrison@vger.nsu.edu claims
to demonstrate how to use generics to emulate procedure variables in
Ada.  I suggest, however, that he really demonstrates how to produce something one
might call `procedure statics'.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1991-02-15 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1989-01-16 17:17 Procedure variables Dale Worley
  -- strict thread matches above, loose matches on Subject: below --
1991-02-15 10:16 procedure variables forsyth

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