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!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed-00.mathworks.com!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Ada202X: Easy to use "UML private"-like components Date: Fri, 21 Jun 2013 14:36:40 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <69246de0-4b33-4d47-b5be-a45e8c911fb0@googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1371839800 32518 192.74.137.71 (21 Jun 2013 18:36:40 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 21 Jun 2013 18:36:40 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:ewqhh4iEIOxCMfEyZY2bu+yf5X4= Xref: news.eternal-september.org comp.lang.ada:15878 Date: 2013-06-21T14:36:40-04:00 List-Id: Martin writes: > Secondly, I have to explain that using Ada "private" gives you "UML protected": Not exactly. Ada "private" means clients can't see it, but child packages (which should be thought of as part of the same abstraction) can. It's a completely different visibility model than UML. I don't see any reason to be embarrassed about that. > Option 2: > type T is tagged record > null; > private > F : Float; > end record; > > > I prefer Option 2. > > Thoughts? I don't think making Ada more like UML is a worthwhile goal. If it were, I'd prefer your option 1. But I don't see the point: In Ada, packages are about visibility. That's different from languages that conflate the concept of "module" and "type" (which has both advantages and disadvantages). Overall, I prefer the Ada way. If you want derived types to see their parent types components, you put the derived types in a child package; if you don't, then you don't. Attempts to mimic UML in Ada lead to a mess, as you've shown. I share your disdain for what you called "opaque" types -- it forces you into heap management, which leads to extra trouble. But I object to calling them "opaque" types. Ada folks usually call them "stt access types" and "stt incomplete types", or "Taft amendment types", because they were invented by Tucker Taft and added to Ada 83 at the last minute when nobody realized all the headaches they cause for compiler writers. The term "opaque type" comes from Modula-2, IIRC, and is more like an Ada private type, with some annoying restrictions added. - Bob