From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3dbf2f325f33ce35 X-Google-Attributes: gid103376,public From: Tucker Taft Subject: Re: Elimination of "use" clauses Date: 1999/07/23 Message-ID: <3798E50D.100976B@averstar.com>#1/1 X-Deja-AN: 504555967 Content-Transfer-Encoding: 7bit Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.burl.averstar.com References: <377B5807.88B875E0@cs.york.ac.uk> <7lh74s$v36$1@nnrp1.deja.com> <7ligdq$c8q$1@nnrp1.deja.com> <7ljb4e$na9$1@nnrp1.deja.com> <7ltus1$ah1@dfw-ixnews19.ix.netcom.com> <7mrjus$bet@dfw-ixnews14.ix.netcom.com> <7n0icj$1je@dfw-ixnews21.ix.netcom.com> Content-Type: text/plain; charset=us-ascii Organization: AverStar (formerly Intermetrics) Burlington, MA USA Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-07-23T00:00:00+00:00 List-Id: Richard D Riehle wrote: > > In article , > dale@cs.rmit.edu.au (Dale Stanbrough) wrote: > > >Export directives -could- do it (and it is not a bad idea at all), > >but we shouldn't forget that Ada already has the ability to export > >-just- the operators we want, and it's called using a private type > >and only advertising the appropriate operations. > > I fully agree that the private type is underused for this purpose. > However, you will need to declare the arithmetic and logical > operators for a private type. This is the ideal place for using > a nested Ops package to restrict the set of operators to exactly > those you want available in your design. > > package P is > type T is private; > -- operations on T > package Ops is > function ">" (L, R : T) return Boolean; > function "+" (L, R : T) return T; > end Ops; > end P; > > Now, use P.Ops makes sense and exports only the operators the > designer feels are appropriate but still restricts them to an > Ops package. Of course, if they were not in the nested Ops package, > one could still invoke the "use type" clause. In the end, I think it > it will be a matter of preference rather than a matter of which is > better. The major difference is that the operators are no longer inherited as part of a derived type definition. In general, the "ops" package idiom was an Ada 83 work-around. Now that we have use-type, I recommend against proliferating it further. There are ways to work with a language, and ways to fight against it. In Ada 95, the "use type" is definitely the language-defined way to deal with operator visibility. In Ada 83, there really wasn't any particularly good language support for operator visibility, so various approaches were adopted. > ... > Richard Riehle > richard@adaworks.com > http://www.adaworks.com > -- -Tucker Taft stt@averstar.com http://www.averstar.com/~stt/ Technical Director, Distributed IT Solutions (www.averstar.com/tools) AverStar (formerly Intermetrics, Inc.) Burlington, MA USA