Newsgroups: comp.lang.c++,comp.lang.smalltalk,comp.lang.eiffel,comp.lang.ada,comp.object
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!portc02.blue.aol.com!howland.erols.net!cs.utexas.edu!chi-news.cic.net!metro.atlanta.com!uunet!in1.uu.net!uucp3.uu.net!alexandria.organon.com!alexandria!jsa
From: jsa@alexandria (Jon S Anthony)
Subject: Re: OO, C++, and something much better!
In-Reply-To: Alan Lovejoy's message of Thu, 30 Jan 1997 02:25:09 -0800
Message-ID: <JSA.97Jan30205754@alexandria>
Sender: news@organon.com (news)
Organization: Organon Motives, Inc.
References: <JSA.97Jan16141937@alexandria> <E44u82.6uB@syd.csa.com.au>
	<mheaney-ya023280001601972303180001@news.ni.net>
	<32DF458F.4D5C@concentric.net> <32DF94DC.6FF8@watson.ibm.com>
	<32DFD972.37E4@concentric.net> <5bphq4$5js@mulga.cs.mu.OZ.AU>
	<32E05FAF.47BA@concentric.net> <5buodl$bci@boursy.news.erols.com>
	<32E2FEC7.2F7B@concentric.net> <5bvncj$gqg$1@A-abe.resnet.ucsb.edu>
	<32E47B4B.56D9@concentric.net> <32E4E6E1.437E@dstsystems.com>
	<32EE858E.FAD@concentric.net> <5cobea$cm8@news1.ucsd.edu>
	<32F07705.289C@concentric.net>
Date: Fri, 31 Jan 1997 01:57:54 GMT
Lines: 73
Xref: glinda.oz.cs.cmu.edu comp.lang.c++:244575 comp.lang.smalltalk:50589 comp.lang.eiffel:18043 comp.lang.ada:56937 comp.object:60638

In article <32F07705.289C@concentric.net> Alan Lovejoy <alovejoy@concentric.net> writes:

> And I agree that the way static typing is done in Ada, Modula-3 and
> Eiffel is quite superior to what C++ does. But I would be even
> happier with the way Ada or Eiffel handle typing if one could
> simultaneously have two different variables whose static type
> constraint is "Dictionary" but where each is actually an instance of
> a different class (say HashTable and BinaryTree)--and the only class
> they both have in common in their inheritance hierarchy is Object.

But you can do that in either of them - though it is not particularly
clear _why_ you would ever _want_ to do this.  So, what's the problem
here???  Actually, you can do this in several different ways depending
on what it is you really want.  For example, in Ada:


package Objects is
    type Object is abstract tagged limited null record;
...
end Objects;


package Tables.Hash_Tables is
    type Hash_Table is new Object with private;
...
end Tables.Hash_Tables;


package Trees.Binary_Trees is
    type Binary_Tree is new Object with private;
...
end Trees.Binary_Trees;


package Dictionaries is
    type Dictionary(Impl : access Object'Class)
        is new Object with private;
...
end Dictionaries;

....

    D1 : Dictionary(new Hash_Table);
    D2 : Dictionary(new Binary_Tree);


There are several other ways of doing this, depending on what you are
fishing for, which have various tradeoffs and flexibilities.  Shrug.


> 	VAR
> 
> 		dictionary1, dictionary2: Dictionary;
> 
> 	BEGIN
> 	
> 		dictionary1 := new HashTable;
> 		dictionary2 := new BinaryTree;
> 
> Does that answer your questions?


Does the above answer yours????


/Jon
-- 
Jon Anthony
Organon Motives, Inc.
Belmont, MA 02178
617.484.3383
jsa@organon.com

