comp.lang.ada
 help / color / mirror / Atom feed
From: barmar@think.COM (Barry Margolin)
Subject: Re: Procedure types and dynamic binding
Date: 11 Jan 89 17:51:21 GMT	[thread overview]
Message-ID: <35339@think.UUCP> (raw)
In-Reply-To: 4062@hubcap.UUCP

In article <4062@hubcap.UUCP> wtwolfe@hubcap.clemson.edu writes:
>    Ada is a state-of-the-art applications programming language, not
>    a state-of-the-art research language.  Perhaps a more appropriate
>    approach to procedural variables would be to incorporate them into
>    a research language and look for a) efficient implementations,
>    including code optimization, and b) realistic situations in which 
>    the use of procedural variables is effectively not optional.   

I'm really beginning to wonder what universe you're coming from. :-)

Procedure variables are hardly a research topic these days.  They've
been in production use for decades.  And I can't think of any reason
why any decent compiler implementor wouldn't be able to implement them
efficiently (the only inefficiency I know of is minor - procedures
assigned to variables must get their own stack frame, rather than
being able to share its parent block's stack frame - and does not
exist if procedure assignment is restricted to top-level procedures).

They've been in use in the Lisp programming world for years.  They are
great for AI applications in which objects must have highly variable
active properties.  Simple object-oriented systems can be implemented
using either "upward closures" (functions that remember the lexical
environment from which they were returned) or structures that contain
data and a procedure object.

They are used quite effectively on Multics, which has extended PL/I to
support procedure variables.  The most obvious use is in the
device-independent I/O library.  The structure that represents an I/O
stream mostly contains procedure objects that implement the
device-specific portion of each I/O operation.  When you call the
device-independent routines they dispatch through the appropriate
component of the stream structure.  The components that represent
operations that are not appropriate (either because of the type of
device or the state of the stream) can be filled in with procedures
that return appropriate error indications.  But all of the above can
be done with extra flags in the structure and CASE statements.  Where
it really comes in handy is when you allow new device drivers to be
linked in on the fly (Multics has been doing dynamic linking for over
twenty years, and there's a system call to explicitly invoke the
dynamic linking mechanism and return a procedure object).

I guess this doesn't provide any more fundamental capabilities than
the runtime recompilation mechanism you've mentioned.  But I sure
wouldn't want to use a system that implemented dynamic linking by
automatic editing, recompilation, linking and invocation of the
application.  True dynamic linking is often criticized as being too
slow, but it must be several orders of magnitude than the most
well-optimized recompilation scheme.

Algol-68 (or was it Algol-60?) had procedure variables, at least in
the form of call-by-name parameters.  And there are many good uses for
them in C, such as the parameter to the signal() subroutine, which
associates a procedure with a software interrupt.

I could probably go on and on.  Procedure variables are an elegant way
to reduce the complexity of an enormous number of programs.  When I
first saw Ada I noticed two things: 1) the syntax is excessively
verbose and contorted (I really hate the way the verb "IS" is used,
for some reason even I don't understand), and 2) no procedure
variables.


Barry Margolin
Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar

  reply	other threads:[~1989-01-11 17:51 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 [this message]
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,
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