On Fri, 03 Oct 1997 14:25:43 MET_DST [log in to unmask] wrote:
> There are in fact 2 different and complementary problems to solve:
>
>
> 1) The ability to write, once for sall, a package for Lists (or any other
> structure) of one (but ANY) type T of objects, with the lowest adaptation cost
> for a specific type t.
>
> This first problem is solved by GENERICITY in the Ada sense (see for
> instance my own Fortran 90/95 Data Structures book).
>
>
> 2) For a given list (be it generic or not), the ability to mix different kind
> of objects in it.
>
> Solutions are:
> 2.1) use of TRANSFER function, as exposed through the Mail discussion.
> 2.2) simulate a variant derived type for the above type T (the "generiic
> parameter" of the List Data Structure).
>
>
> Note that both problems make sense only in a typed language.
> In a typeless language such as Lisp, you simply define a List structure,
> and objects in it are of any kind.
>
> Hope this helps to "resume" (RESUMER in french) the discussion?...
This is a masterly summary of the problem. Algol-68 attempted to solve both
problems by introducing a "UNION type" which allowed objects to be declared
that could take one of a list of alternative types. The language was
constrained so that it was illegal to take out a different type object from
that which was previously stored in any variable. This proved to be still too
constrained and the most effective implementation of the language Algol-68R,
introduced a special type, called from memory ANYTYPE, which was effectively
a union of any type. One of the major complications with this was the rules
for argument matching and procedure overloading. Does a union match only with
a union with the same list of constituent types? Does an anytype match only
with a an anytype? How can an anytype object be used as an argument to a
procedure which calls for an object of one of the specific types? This was
one of the few areas that I believe Algol-68 got somewhat wrong, however, it
is some years since I looked at it and I can't remember in detail how this
was handled.
The approach did give a highly controlled way of handling the generic type
issue without the overheads of runtime dynamic binding.
I would have though solving this issue was a significant further factor in
adding truely useful OOP facilities.
--
Lawrie Schonfelder
Director, Computing Services Dept.
The University of Liverpool, UK, L69 7ZF
Phone: 44(151)794 3716, Fax: 44(151)794 3759
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|