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-Thread: 103376,999932ecc319322a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!newscon02.news.prodigy.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: advice on package design Date: 12 Mar 2005 14:57:17 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1110212638.336123.298580@l41g2000cwc.googlegroups.com> <1gbk0qx2sgzpg$.sltzfssofla8$.dlg@40tude.net> NNTP-Posting-Host: shell01-e.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1110657437 32588 69.38.147.31 (12 Mar 2005 19:57:17 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 12 Mar 2005 19:57:17 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:9255 Date: 2005-03-12T14:57:17-05:00 List-Id: "Dmitry A. Kazakov" writes: > 3. You can rename parts of contents of Baz in Foo: > > package Foo is > type Word is ... > package Baz is new Bar (Word, ...); > > subtype Linked_List is Baz.Linked_List; -- "renaming" of a type > procedure Insert (...) renames Baz.Insert; -- renaming of a procedure > ... > end Foo; One variation on that is to declare a derived type: type Linked_List is new Baz.Linked_List; This causes all of the primitive subprograms of Baz.Linked_List to be inherited -- implicitly declared in Foo. But for anything that's not a primitive subprograms, you have to write some wrapper code by hand. If I were [re]designing Ada, I would make 'use' transitive. That is, if Foo says "use Linked_List" that would make the contents of Linked_List directly visible in Foo, and anything that says "use Foo;" would have direct visibility on everything directly visible in Foo -- not just the things *declared* in Foo. Or something like that. It really is a flaw in Ada that you can't easily re-export stuff. The renaming solution is bad because it is verbose, and therefore error prone. I still remember a bug I fixed many years ago: function "and"(...) return ... renames Something."and"; function "or"(...) return ... renames Something."or"; function "xor"(...) return ... renames Something."or"; The problem is that renaming is *not* usually used to rename things -- it is used to import them (with the *same* name) into a different scope. Given that mindset, it took me a *long* time to notice the bug in the above. The symptom was that xor was behaving strangely in some faraway place. That was Ada 83. In Ada 95, "use type" would have prevented the problem. - Bob