comp.lang.ada
 help / color / mirror / Atom feed
From: billwolf@hubcap.clemson.edu (William Thomas Wolfe,2847,)
Subject: Re: Procedure types and dynamic binding
Date: 7 Jan 89 21:21:46 GMT	[thread overview]
Message-ID: <4037@hubcap.UUCP> (raw)
In-Reply-To: 5790@medusa.cs.purdue.edu

From article <5790@medusa.cs.purdue.edu>, by rjh@cs.purdue.EDU (Bob Hathaway):
> 
>>> 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.  

     No, all we need is the ability to have pointers which are not bound
     to any specific type.  Most of the time we want to say "pointer to
     SPECIFIC_TYPE", but sometimes we just want to say "pointer".  Given
     the ability to specify an unrestricted pointer, we can implement
     the desired stack (or whatever) of any element type. 
 
> Now, adding polymorphic parameters to Ada would be a sizable extension

     Not true; all we need to do is write procedures which require an
     arbitrary pointer as a parameter, and we're done.

> 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.  

     Quite true, and pointers should be restricted wherever it is reasonable
     to do so, just as ranges should be specified whenever appropriate.

# 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.

     Unless, as I have shown above, a simpler mechanism will suffice.

#>> 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.

   Using the above mechanism, we've eliminated the case statements.

   Now set up your abstraction to provide a "current node" concept,
   along with operations like DESCEND_LEFT, DESCEND_RIGHT, and ASCEND.
   This can be implemented either via parent pointers or via a secret
   stack which holds the path of descent used to reach the current node.



                                           Bill Wolfe

                                    wtwolfe@hubcap.clemson.edu

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