comp.lang.ada
 help / color / mirror / Atom feed
From: rjh@cs.purdue.EDU (Bob Hathaway)
Subject: Re: Procedure types and dynamic binding
Date: 7 Jan 89 18:05:00 GMT	[thread overview]
Message-ID: <5790@medusa.cs.purdue.edu> (raw)
In-Reply-To: 4018@hubcap.UUCP


>> I don't think procedural variables or class structures will make Ada
>> much bigger.  Procedural variables are not complicated in Modula [...]
>
[Bill Wolfe responds]
>    But Modula doesn't have generics.  Using the combination of generics
>    and the class abstraction outlined in my earlier article, I think
>    we'll get more power, with better readability.
>

Yes, class structures with generics would provide good data abstraction.
This would allow classes to be statically parameterized by types, variables, 
constants, and subprograms.  Generics are good for setting an Adt once, such as
a stack which is parameterized by its element type and a print subprogram.  
But what about dynamic parameterization?  For dynamic parameterization of data,
polymorphic parameters to Adt operations are needed to allow the greatest 
expressiveness.  An example is a stack of any element type which could be
provided by polymorphic parameters to an insert subprogram.  For dynamic 
parameterization of operations, procedural variables are needed.  An example
is a stack which can change its print operation as described previously.

Now, adding polymorphic parameters to Ada would be a sizable extension but 
adding procedural variables would be almost trivial.  Admittedly, Adt 
designers can provide a plethora of operations and programmers can use case 
statements to choose among them but this puts greater burden on the programmer
since they must now select the correct operation throughout their code.  Also,
static generic parameterization is desirable in certain cases such as in the
stack example above when the element type is known in advance and the type
system can statically perform strong typechecking for correctness.  But the
flexibility of dynamic parameterization allows maximum expressiveness 
and greater power, and so "the burden of proof" has to be made against
dynamically parameterized operations.  Since static generics and dynamic
parameterization are not mutually exclusive, both could be provided.

>> This isn't what I had in mind.  What if variables of type Tree_Type should
>> be traversed in different ways depending on context?
>
>    Just make basic traversal operations a part of your abstraction.
>

But this calls for case statements throughout the program to determine which 
operation to call, as mentioned above.  For maximum expressiveness, I might
want to set instances with particular traversal operations and then use a
single operation invocation at a later point in the program which will invoke
the correct operation for all instances, reducing redundant code and allowing 
maximum expressiveness.


					Bob Hathaway
                                        rjh@purdue.edu

  reply	other threads:[~1989-01-07 18:05 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 [this message]
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,
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