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,8ca14c11fd6d2e56 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newspeer2.se.telia.net!se.telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mail From: =?ISO-8859-1?Q?Bj=F6rn_Persson?= User-Agent: Mozilla Thunderbird 1.0.2-1.3.3 (X11/20050513) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: generic parameter Copy for primitifs types. References: <1119544911.159343.288010@g43g2000cwa.googlegroups.com> In-Reply-To: <1119544911.159343.288010@g43g2000cwa.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Date: Thu, 23 Jun 2005 18:30:08 GMT NNTP-Posting-Host: 217.209.116.179 X-Complaints-To: abuse@telia.com X-Trace: newsb.telia.net 1119551408 217.209.116.179 (Thu, 23 Jun 2005 20:30:08 CEST) NNTP-Posting-Date: Thu, 23 Jun 2005 20:30:08 CEST Organization: Telia Internet Xref: g2news1.google.com comp.lang.ada:11600 Date: 2005-06-23T18:30:08+00:00 List-Id: nblanpain@hotmail.com wrote: > generic > type T_Item is private; > with procedure Copy (Left : in out T_Item; Right : in T_Item); > package Toto is > .... > end Toto; > ------ > > At instanciation, for T_Item = Integer for example, is there a methode > to take for Copy => ":=". Must I redefined Copy ? Can I say that, by > default, take ":=" ? The normal way when you need to do special things during assignment is to use a controlled type. That is, you derive from Ada.Finalization.Controlled and override Adjust: type Special_Type is new Ada.Finalization.Controlled with record ... procedure Adjust (Object : in out Special_Type) is ... Then, instead of a Copy procedure you just use ":=", and Adjust will be called. (See RM 7.6.) Your generic package would then look like this: generic type T_Item is private; package Toto is ... end Toto; package Integer_Toto is new Toto (Integer); package Special_Toto is new Toto (Special_Type); Or is there a reason why controlled types wouldn't work in your case? -- Bj�rn Persson PGP key A88682FD omb jor ers @sv ge. r o.b n.p son eri nu