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,6cb2525ffbfe23ce X-Google-Attributes: gid103376,public From: collins@cs.wm.edu (Bob Collins) Subject: Re: Why both "with" and "use"? Date: 1999/02/14 Message-ID: #1/1 X-Deja-AN: 444279212 References: <36C5B28C.F32C43A4@jps.net> <7a4f85$rh1$1@remarQ.com> <7a4j3h$64e@drn.newsguy.com> <7a4pem$qlc$1@remarQ.com> <7a6jho$nkv$1@remarQ.com> X-Complaints-To: abuse@home.net X-Trace: news.rdc1.va.home.com 919005290 24.2.56.132 (Sun, 14 Feb 1999 07:14:50 PDT) Organization: Computer Science @ William & Mary NNTP-Posting-Date: Sun, 14 Feb 1999 07:14:50 PDT Newsgroups: comp.lang.ada Date: 1999-02-14T00:00:00+00:00 List-Id: In article <7a6jho$nkv$1@remarQ.com>, "Pat Rogers" wrote: > Yes, the package isn't part of the type itself, but let's go back for > a moment to the definition I gave of an ADT: "a set of legal > operations (the "primitives") and legal values, and little else." It > is the "little else" that packages provide, and IMHO and ADT without > that aspect is not an ADT. We're in agreement overall, of course, but > I think it is important to stress that, in addition to the demarcation > of the primitives, as you've said above, the encapsulation of the > type's representation is an essential aspect of an ADT. Without > packages, we have no encapsulation, no information hiding. In the Guttag-Horning-Liskov formulations of the algebraic specifications of ADTs, errors were important values. The Ada package allows errors in ADTs very naturally, as exceptions declared inside the package. Every stack ADT need an Empty_Stack exception declaration for completeness as an ADT and possibly a Stack_Overflow exception declaration as a practical convenience. These are the kinds of things that are more than the "little else" mentioned above. Also, when the TOI (type of interest) in each of two type algebras is a supporting type in the other, it is programmatically convenient to include both ADTs in the same package. In this thread, we've already seen an example of a structure and its iterator in the same package. -- Bob Collins