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,79d6bba6ba97b840 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Renaming of procedures in a generic instantiation References: Date: Sun, 26 Sep 2010 04:45:18 -0400 Message-ID: <828w2orizl.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (windows-nt) Cancel-Lock: sha1:0rb5wDdthBFUxDTWmF7ZN59YqU0= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 904a54c9f080fe029e66110989 Xref: g2news1.google.com comp.lang.ada:14268 Date: 2010-09-26T04:45:18-04:00 List-Id: Gene writes: > I'm confused about an aspect of renaming. It boils out to this little > example: > > with Ada.Containers.Ordered_Sets; > > package Foo is > > type Queue is private; > > procedure Add(Q : in out Queue; Item : in Integer); > > function Is_Empty(Q : Queue) return Boolean; > > private > > package Queues is > new Ada.Containers.Ordered_Sets(Integer, "<", "="); > type Queue is new Queues.Set with null record; All primitive operations of Queues.Set are implicitly declared here, with Queue replacing Queues.Set; that includes Set and Is_Empty. That's what derived types are for. > end Foo; > > package body Foo is > > procedure Add(Q : in out Queue; Item : in Integer) > renames Insert; This 'Insert' resolves to Foo.Insert (Container : in out Foo.Queue; ...); > function Is_Empty(Q : Queue) return Boolean > renames Queues.Is_Empty; Queues.Is_Empty expects a Constainer of type Foo.Queues.Set, not Foo.Queue. If you replace type Queue is new Queues.Set with null record; with subtype Queue is Queues.Set; Then the Add renames will fail (because the primitive operations are not derived), and the Is_Empty will succeed. -- -- Stephe