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,81e608b9d333eaff X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!news.glorb.com!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 Subject: Re: Generics and selection based on type Newsgroups: comp.lang.ada References: User-Agent: KNode/0.10.4 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8Bit Message-ID: Date: Fri, 12 Jan 2007 21:43:57 GMT NNTP-Posting-Host: 83.250.96.174 X-Complaints-To: abuse@telia.com X-Trace: newsb.telia.net 1168638237 83.250.96.174 (Fri, 12 Jan 2007 22:43:57 CET) NNTP-Posting-Date: Fri, 12 Jan 2007 22:43:57 CET Organization: Telia Internet Xref: g2news2.google.com comp.lang.ada:8125 Date: 2007-01-12T21:43:57+00:00 List-Id: Maciej Sobczak wrote: > I would like to write a generic function that returns the string > representation of its parameter, which can be a number or a string. [...] > For this, it would be good to be able to select the implementation of > To_String based on what the type is. If it's numeric - the 'Image > attribute can be used. If it's already String - just return the > argument. And so on. > > Is it possible? I think that's impossible. You can only do things with the parameter that you can do with all types that the generic function can be instantiated with. I also don't see the point. Why don't you simply write a set of overloaded functions? It won't take more work or more code, as you'll have to write all the different implementations either way. Generics are for cases where you can use the same implementation for different types. -- Bj�rn Persson PGP key A88682FD omb jor ers @sv ge. r o.b n.p son eri nu