From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 30 Oct 92 02:39:10 GMT From: alex@MIMSY.CS.UMD.EDU (Alex Blakemore) Subject: Re: User-defined assignment Message-ID: <61612@mimsy.umd.edu> List-Id: In article <11237@platypus.uofs.uofs.edu> beidler@guinness.cs.uofs.edu (Jack Be idler) writes: > I wonder if Booch had to do it all over again if he would have used > limited private types. [for generic formal types ?] I sure hope so, exporting limited but importing non limited types makes composing abstractions close to impossible. if anything, that strategy is completely backwards. > By requiring that limited private types be supplied with the correct resource s > the client is not longer hindered by a lack of ":=" . absolutely. whenever you see generic type xxx is private; instead of generic type xxx is limited private; function "=" (left, right : xxx) return boolean is <>; -- only if needed procedure assign (left in out xxx; right : xxx); -- ditto little warning signs should go off. The first form makes predefined equality and assignnment visible & its impossible to tell from the generic spec whether they are used (i.e. the assumptions remain unstated). It is also impossible to instantiate the generic using any other form of equality and assignment. This means you cant instantiate it with a limited private type - and an access type wont work (as Booch suggests) because you end up testing whether the pointers are the same instead of the objects. In spite of any irritation you may have had with limited private types, it really helps to make generic formal types limited instead of private. This causes the generic writer to type a little more but makes the generic package more general. This is entirely different from the decision as to whether to make exported types limited - in that case judgement is required. I cant think of a single good reason to ever import a private type instead of a limited private type. -- --------------------------------------------------- Alex Blakemore alex@cs.umd.edu NeXT mail accepted