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,943350d29d278e69 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.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: Generic package with dynamic subprogram name? References: Date: Thu, 10 Jun 2010 03:33:11 -0400 Message-ID: <82eigfnxzc.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (windows-nt) Cancel-Lock: sha1:rp+nMexLxGEctTJApF6pYIQoS7c= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 1f8934c109546e197caa705789 Xref: g2news1.google.com comp.lang.ada:11558 Date: 2010-06-10T03:33:11-04:00 List-Id: Marek Janukowicz writes: > generic > Attr : String; > package Get_Set is > function Get_Attribute return String; > procedure Set_Attribute ( Value : String ); > end Get_Set; > > But if I then instantiate: > package Get_Set_First_Name is new Get_Set( "FirstName" ); > package Get_Set_Last_Name is new Get_Set( "LastName" ); > > subprogram names will overlap. I know I can call them using package prefix, > but I'd really like to have nice API like here: > Get_First_Name( ... ); > Set_Last_Name( ... ); Use better names for the generic, so the package prefix is not just noise: generic Attribute : String; package Attributes is function Get return String; procedure Set ( Value : String ); end Get_Set; package First_Name is new Attributes( "FirstName" ); package Last_Name is new Attributes( "LastName" ); First_Name.Get( ... ); Last_Name.Set( ... ); > I understand things I ask about in the subject are most likely not possible, > but is there any other way to achieve what I want? Renames was suggested. Writing all of those can get tedious, and probably defeats the purpose of the generic. Using an ASIS application to generate code would be another way. -- -- Stephe