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: Samuel Mize Subject: Re: Why both "with" and "use"? Date: 1999/02/16 Message-ID: <7aciq3$1vu@news3.newsguy.com>#1/1 X-Deja-AN: 445065867 References: <36C5B28C.F32C43A4@jps.net> <7a4f85$rh1$1@remarQ.com> <7a4j3h$64e@drn.newsguy.com> <7a4pem$qlc$1@remarQ.com> Organization: ImagiNet Communications, Ltd. User-Agent: tin/pre-1.4-981002 ("Phobia") (UNIX) (AIX/3-2) Newsgroups: comp.lang.ada Date: 1999-02-16T00:00:00+00:00 List-Id: Matthew Heaney wrote: > "Pat Rogers" writes: >> A package serves more of a central purpose in Ada 95, especially when >> it exports a tagged type declaration. >> >> The big difference (or, at least one difference) between Java packages >> and Ada packages is that the combination of an Ada package and a >> private type defines an Abstract Data Type. > I wouldn't quite phrase it that way. With respect to the declaration of > a type (and I mean _any_ kind of type, not just ADTs), You're absolutely right, for types. I believe that Pat is defining a coding construct, which he calls an ADT. This is a free-standing, completely encapsulated type. It includes its user-visible values, operations, and exceptions, and nothing else, and has a syntax-level "wall" around it. This construct can be directly supported by combining Ada's types and packages. I believe Pat is saying that the same is not true of Java's types and packages. Heaven knows there are lots of other ways to use types and packages. > Perhaps I am being pedantic, I don't think so. >but I don't regard a package as part of a > type. I regard the type as its name, values, and (primitive) > operations. The package is just syntactic overhead necessary to > identify the primitive operations, but the package itself is not part of > the type. That's the point. A type isn't necessarily encapsulated. Its definition can be jumbled together with the definitions of othere types, in ways that create semantic linkages. Encapsulation is the job of a package. This is Ada's building-block approach. If you want your type to be a completely encapsulated "ADT," slap it into its own package. If not, don't. The package is part of the ADT design construct, but certainly not part of the type. > When they give me a bag at the supermarket to hold my groceries, it's the > groceries that I am interested in, not the bag. If I were to make a > list of the things I picked up at the store, I probably wouldn't include > the bag in that list. To strain the analogy a little, suppose you got groceries for three people. You might put them in separate bags, for ease of handling. >From that viewpoint, the list might be "my groceries, Pat's groceries, and Sam's groceries." You would list neither the bags nor the contents at that level of abstraction. Best, Sam Mize