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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c05bdbf8e48c4dfa X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Generic operation and prefixed notation Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Mon, 14 Jun 2010 20:09:06 +0200 Message-ID: NNTP-Posting-Date: 14 Jun 2010 20:09:05 CEST NNTP-Posting-Host: 01ab0831.newsspool2.arcor-online.net X-Trace: DXC=33K:k;nVZWIC4i^e1BZ=_HA9EHlD;3YcB4Fo<]lROoRA8kF On Mon, 14 Jun 2010 19:47:09 +0200, Marek Janukowicz wrote: > I'm still working on a problem I asked about last week (thanks for all the > answers). Another question that arose recently: is there any way of calling > an instantiation of generic operation with prefixed notation? > > Given a simplified example: > > type Model is tagged record > null > end record; > > generic > Attr_Name : String; > procedure Get_Attribute( M : Model ); > > procedure Get_Name is new Get_Attribute( "Name" ); > > Now I can call it with: > Get_Name( M ); > > but I'd rather use > M.Get_Name; > > which complains about Get_Name not being present. > > Is there any other way to achieve it? Prefix notation is considered harmful. Anyway,. you need the operation primitive: One unit, declares the interface: type Abstract_Model is abstract tagged null record; procedure Get_Name (M : Abstract_Model) is abstract; Same or another unit, provides a generic implementation: generic type Model_Type is new Abstract_Model with private; Attr_Name : String; procedure Get_Attribute (M : Model_Type); Yet another unit brings both together: type Model is new Abstract_Model with null record; overriding procedure Get_Name (M : Model); In its body: procedure Get_Name_Implementation is new Get_Attribute (Model, "Name"); procedure Get_Name (M : Model) renames Get_Name_Implementation; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de