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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Extending a third party tagged type while adding finalization Date: Thu, 7 Dec 2017 17:22:41 -0600 Organization: JSA Research & Innovation Message-ID: References: <4db43571-7f86-4e73-8849-c41160927703@googlegroups.com> <6496a10f-c97e-4e42-b295-2478ad464b2f@googlegroups.com> <6106dfe6-c614-4fc1-aace-74bf8d7435e3@googlegroups.com> <24767ee5-cda8-45e4-98d1-7da44757bd40@googlegroups.com> <037e7f02-9149-4648-b7c5-91f67c1c1961@googlegroups.com> Injection-Date: Thu, 7 Dec 2017 23:22:41 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="7526"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:49410 Date: 2017-12-07T17:22:41-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:p0auie$h5h$1@gioia.aioe.org... > On 07/12/2017 02:13, Randy Brukardt wrote: >> "Dmitry A. Kazakov" wrote in message >> news:p07343$1tst$1@gioia.aioe.org... >>> On 2017-12-05 22:09, Randy Brukardt wrote: >> ... >> The above >> is much too complex. It could be simplified a lot: >> >> An ADT is a data type (from the perspective of a client of a type) >> defined >> solely by the operations defined for that data type. This was a bit sloppy; it should also have required the operations to be defined explicitly and as a closed set of operations. > 1. That does not apply to Ada since it has named type matching. Therefore > you can have two different types with identical operations. This doesn't seem relevant. I don't see anything in my definition that prevents one from having two different but identical ADTs. If you think there is, imagine whatever words you think would be needed to have that effect. > 2. You cannot do anything with a type otherwise than through its > operations. So the definition would be useless without splitting > operations into "operations operations" and not "quite operations", which > you apparently trying to do. Definitely. As I mentioned earlier, there is a closed, finite set of operations involved in an ADT. There can be other operations that are built on the set of operations, but they are definitely not part of the ADT. If the set of operations is not closed, then one cannot abstractly reason about the ADT, defeating the purpose of the definition. (It also defeats reusability, which is rather the point of defining ADTs in the first place. >> For Ada, this means that an ADT is a private type (possibly tagged) with >> (usually explicit) primitive operations, and that there are no end-runs >> on >> those primitive operations. All other uses of the ADT are built out of >> those >> primitives. > > Why does it follow? > > 1. Private type means that parts of the representation is hidden. Your > definition is not related to that. All of the operations need to be explicit and a closed set. If the representation is not hidden, that cannot be true. QED. (Yes, my definition was sloppy. So what?) > 2. Primitiveness of an operation is not related either. If the type is private, the operations have to be declared there, and that makes them primitive. (No Ada ADTs outside of an Ada package.) >> If a type is not private, it cannot be an ADT, as it provides an >> unlimited >> number of other operations that are not described explicitly. > > How primitiveness changes that? I still can define new subprograms taking > and returning values of the type regardless. If they're not part of the package, then they are operations that use the ADT, but are not part of the ADT. For many programs, most of the code is built on ADTs but are not themselves part of any ADT (because they require the services of many ADTs - which one does it belong to? Any answer is arbitrary). ... >> With the >> Wikipedia definition above, every Ada data type is an ADT, since every >> type >> can be described this way (every operation on a numeric type is described >> by >> the Ada Standard, after all, and a client can use nothing else). That's a >> completely useless definition. > > ADT is the semantics it implements. You first have the semantics > (mathematical model of the problem space) and then an implementation of. > > Non-ADT is ad-hoc semantics deduced from a given representation. You take > 'int' from the compiler and then try to figure out if it can be useful for > you. > > That is the difference. Based on this definition, almost nothing should be an ADT, because very little can be described only by its semantics. Humm, that's actually a true statement; probably we are feeling different parts of the elephant and describing it very differently. Still, you seem to think of an ADT as a constantly increasing (and ad-hoc) set of operations, while I view only the operations declared directly with the (private) type as part of the ADT. Reasoning ability alone requires a minimum set of operations (but I wouldn't want to require that explicitly in a definition lest programmers get tied up trying to eliminate excess operations -- not worth the work). Randy.