comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: Specialization of generics
Date: Mon, 04 Jun 2001 14:51:00 GMT
Date: 2001-06-04T14:51:00+00:00	[thread overview]
Message-ID: <ofNS6.3787$v4.179175@www.newsranger.com> (raw)
In-Reply-To: 9ffnvi$qtl$1@news.huji.ac.il

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



  reply	other threads:[~2001-06-04 14:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-04  0:17 Specialization of generics John Pitney
2001-06-04  1:04 ` tmoran
2001-06-04 10:23 ` Ehud Lamm
2001-06-04 14:51   ` Ted Dennison [this message]
2001-06-04 16:16     ` Ehud Lamm
2001-06-04 17:28       ` Brian Rogoff
2001-06-04 19:21         ` Ehud Lamm
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox