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 13:03:59 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!snoopy.risq.qc.ca!chi1.webusenet.com!news.webusenet.com!cyclone1.gnilink.net!news.airnews.net!cabal12.airnews.net!cabal11.airnews.net!sn-xit-03!sn-xit-01!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: "access constant" discriminant Date: Mon, 24 Feb 2003 15:05:53 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <_TO1a.14664$9y2.6601@nwrddc01.gnilink.net> <3CS1a.55972$2H6.1357@sccrnsc04> <3E4E9248.3E71D984@adaworks.com> <1ec946d1.0302201642.66eb93e5@posting.google.com> <1ec946d1.0302241058.88ca487@posting.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:34534 Date: 2003-02-24T15:05:53-06:00 List-Id: Matthew Heaney wrote in message <1ec946d1.0302241058.88ca487@posting.google.com>... >"Randy Brukardt" wrote in message news:... >> >> Claw doesn't use access discriminants. That's in large part because they >> cause limited 'poisoning', as they're restricted to limited types. We >> prefered to use Adjust to make assignment work properly. > >This may simply reflect a philosophical difference about whether types >should be limited or non-limited. Certainly I have never agreed with >the CLAW decision to make window types non-limited, and to me a >non-limited window is completely wacky. That's a consequence of our no access type philosophy. So many people seem to think that O-O means references, and that simply is not true in Ada. The result of our "wackiness" is that you only need to explicitly use access types when you need dynamic (and non-stack-based) allocation of windows. Very few Claw programs have access to windows in them. If I was doing it over, I'd probably have made the windows limited, mainly because of the problems that clones of them cause in a multi-tasking program. But, in general, I tend to be on the side of "provide maximum capability with all reusable object types". Which means non-limited. ... >> Sweeping statements about programming style are not likely to be >> helpful. I tend to feel about finalization like Matt apparently does >> about access discriminants, but the only time I would say something like >> "No serious Ada program can be written without them." is when I'm >> looking for fight. Even though I believe that is true, I'm well aware >> that there are many, many Ada projects which have an irrational fear of >> finalization, and to characterize them as not being "serious" is not >> likely to make any friends. > >Perhaps it was my use of the word "serious" that was confusing. I >should have said "essential," with the same sense that Fred Brooks >used in his famous paper "Essence and Accidents in Software >Engineering." > >http://atheism.about.com/library/glossary/general/bldef_essence.htm > >C++ doesn't require you to use classes, but if you don't, it would be >a stretch to say that you're programming in "C++." Really, you're >using a C++ compiler to compile a C program. This is not necessarily >a bad thing -- after all, C++ gives you better compile-time error >checking and type-safe linkage. But to not use classes you'd be >losing something "essential" to C++ programming. > >The use of access discriminants in Ada95 is exactly analogous. For >example, how would you add controlled-ness to a (tagged) type that is >part of type hierarchy that isn't already controlled? The only way I >know is to do this: > > type NT is new T with private; > ... >private > type Control_Type (O : access NT) is > new Limited_Controlled with null record; > > type NT is new T with record > Control : Control_Type (NT'Access); > ... > end record; > >This is an important Ada95 idiom with which every Ada95 needs to be >thoroughly familiar. This idiom and others like it is why I >characterize access discriminants as "essential" (again, "per se" vs. >"per accidens") to programming in Ada95. Sigh. This is a lousy example, for the simple reason that there should be no such hierarchies. If you can afford the space and time overhead of a tagged type, you can afford the space and time overhead of a controlled type. So there simply should not be any tagged types that aren't controlled. Then this whole example comes up. Secondly, I certainly know of this idiom, but I've never once found a case where I needed to use it. I suspect this comes from the "O-O is everything" mentality, where people are trying to use simulate multiple inheritance in Ada rather than simply solving the problem. Whenever I've needed to "connect" objects, I've always used access-to-classwide types, and added any needed operations. Standing on one's head simply makes tricky, hard-to-maintain code. My point is O-O is the frosting on the cake, not the meat. It's useful for some jobs, but when you start trying to make everything look like it, you get abominations like access parameters and access discriminants. Especially when you try to copy existing O-O dogma instead of realizing that Ada 95 let's you do it better. Randy Brukardt.