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.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8029f6524ed823f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-04 07:51:45 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!news-out.nuthinbutnews.com!propagator!feed2.newsfeeds.com!newsfeeds.com!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <46ba9d66.0106031617.c802df3@posting.google.com> <9ffnvi$qtl$1@news.huji.ac.il> Subject: Re: Specialization of generics Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Mon, 04 Jun 2001 10:51:00 EDT Organization: http://www.newsranger.com Date: Mon, 04 Jun 2001 14:51:00 GMT Xref: archiver1.google.com comp.lang.ada:8065 Date: 2001-06-04T14:51:00+00:00 List-Id: In article <9ffnvi$qtl$1@news.huji.ac.il>, Ehud Lamm says... > >> Now the question: Is it possible to define a generic package taking >> one or more types as generic formal parameters, and then define that >> the generic is instantiated in a different way if the generic formal >> parameters match some condition? One application I could think of >> would be for an image package to handle 1-bit images in a compact way. >> > >Short answer is that generic specialization as such doesn't exist in Ada. >I am sure others will give plenty of useful suggestions how to overcome this >problem. Right. For me the easiest is to just have two generics (one for each "specilization"). Common code can be put in a separate (possibly non-generic) package that both generics can use. For instance, we have a set of packages here for performing multilinear interpolation for specified points using a matrix of values. There's a generic which allows you to instantiate for the number of dimensions you want to use. But for 1 dimension and 2 dimensions the algorithms are much simpler, so they each have their own (non-generic) package. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com