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,8ca14c11fd6d2e56 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!newsgate.cistron.nl!newsfeed.stueberl.de!feed.news.tiscali.de!newsfeed.freenet.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: generic parameter Copy for primitifs types. Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.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: <1119544911.159343.288010@g43g2000cwa.googlegroups.com> <837ivwsz8r2d$.j16zz1529zb9$.dlg@40tude.net> <1119555704.527944.224770@g49g2000cwa.googlegroups.com> Date: Fri, 24 Jun 2005 09:28:10 +0200 Message-ID: <1ormc6uaytixb.v2ogsw0x6y8k.dlg@40tude.net> NNTP-Posting-Date: 24 Jun 2005 09:27:48 MEST NNTP-Posting-Host: 29dac732.newsread2.arcor-online.net X-Trace: DXC=g=>Jb98=\@Tmj<7enW;^6ZC`4<=9bOTW=MN> X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:11610 Date: 2005-06-24T09:27:48+02:00 List-Id: On 23 Jun 2005 12:41:44 -0700, nblanpain@hotmail.com wrote: > But I want to use Copy for other types other than primitifs (integer, > float, boolean...). Though other types have assignment too. So the cleanest way would be either to consistently use it or to make the formal parameter T_Item limited and provide Copy procedure as you did. > The best solution is to set ":=" by default but it > is not possible... True. You can try generic "specialization" like this: ------------ generic type T_Item is limited private; with procedure Copy (Left : out T_Item; Right : in T_Item); package Toto is ... end Toto; with Toto; generic type T_Item is private; package Specialized_Toto is procedure Copy (Left : out T_Item; Right : T_Item); package Toto_Instance is new Toto (T_Item, Copy); end Specialized_Toto; package body Specialized_Toto is procedure Copy (Left : out T_Item; Right : T_Item) is begin Left := Right; end Copy; end Specialized_Toto; ------------- So instantiation with Integer might look like: package Integer_Toto_Implementation is new Specialized_Toto (Integer); package Integer_Toto renames Integer_Toto_Implementation.Toto_Instance; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de