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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,50137bb64a119cfc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-24 08:03:32 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: "access constant" discriminant Date: 24 Feb 2003 08:03:32 -0800 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0302240803.d8cd414@posting.google.com> References: <_TO1a.14664$9y2.6601@nwrddc01.gnilink.net> <3CS1a.55972$2H6.1357@sccrnsc04> <3E4E9248.3E71D984@adaworks.com> <1ec946d1.0302201642.66eb93e5@posting.google.com> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1046102612 5937 127.0.0.1 (24 Feb 2003 16:03:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 24 Feb 2003 16:03:32 GMT Xref: archiver1.google.com comp.lang.ada:34516 Date: 2003-02-24T16:03:32+00:00 List-Id: Lutz Donnerhacke wrote in message news:... > * Matthew Heaney wrote: > > Access discriminants are very powerful. No serious Ada95 program can > > be written without them. > > If there is a serious program without access discriminants, let's call it a > Spark program, or trivial, ok? What I meant was that access discriminants are the sine qua non of Ada95 programming. If you're not using them, you're losing something essential, not accidental (per se vs. per accidens), about an Ada95 program. Of course, this idiom is just a reification of a more general design pattern called the "Adapter Pattern," or more specifically an "Object Adapter." It shows up in myriad languages. You often see C++ written like this: X x; ... Y y(&x); where the object y is bound to object x. Class Y would be implemented as class Y { X* const p public: Y(X* pp) : p(pp) {} //... private: Y& operator=(const Y&); Y(const Y&); }; This shows up even in some Ada95 iterator implementations: Iter : Iterator_Type (Container'Access); Here, you're viewing a container object through an iterator object. Of course, the effect of an object adapter can probably be implemented sans access discriminants (persumably that is the case in SPARK), but I don't consider these alternate locutions as elegant as an access discriminant. In your case you lose access discriminants in order to gain provable correctness -- which is of course the correct tradeoff.