comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: (elementary question) Test on type ?
Date: Wed, 05 Sep 2001 14:19:55 GMT
Date: 2001-09-05T14:19:55+00:00	[thread overview]
Message-ID: <fwql7.4754$4z.14897@www.newsranger.com> (raw)
In-Reply-To: 3b95eca7.5408987@news.demon.co.uk

In article <3b95eca7.5408987@news.demon.co.uk>, John McCabe says...
>
>I don't know whether you missed the original message, but it
>contained:
>
>> Assume:
>>  
>>  
>> -- specification :
>> generic
>>   type T is (<>);
>> function F(X : T) return Float;

Ahh, you're right; I did miss that.


This issue does actually come once in a while too, when you've got code that
needs to be mostly the same, except for one little bit. I think you pretty much
have to hack it. Approaches I have seen:

Make one generic for each type.
Variant 1: Copy and pase the code (maintainence problems).
Variant 2: Use a common subprogram for the common code (cool, but only works if
you don't need to use the generic part in the common code).

Make one generic, hack the difference.
Hack 1: Make the user supply a boolean designating which code path to take.
(flag coupling - fairly bad)
Hack 2: Make the user supply the non-common code themselves as a procedure
parameter. (works well if the non-common stuff can be put together, and it
doesn't rely on package-internal stuff, and you can trust the clients to get
this code right. Not so good if its stuff the clients shouldn't have to worry
about doing themselves.


Hack 1 is really just a special case of Hack 2, where the routine being supplied
is an "Is_Integer" routine, simplified to a boolean. Somewhere in between these
two extremes you may find a good spot.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



  reply	other threads:[~2001-09-05 14:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-04  8:41 (elementary question) Test on type ? Reinert Korsnes
2001-09-04  9:18 ` David C. Hoos, Sr.
2001-09-04  9:29   ` Reinert Korsnes
2001-09-04 11:02     ` Jacob Sparre Andersen
2001-09-04 11:05       ` Reinert Korsnes
2001-09-04 11:39         ` John McCabe
2001-09-04 13:30         ` Marin David Condic
2001-09-04 14:07           ` Ted Dennison
2001-09-04 14:48             ` Marin David Condic
2001-09-04 18:35               ` Mark Biggar
2001-09-04 19:33                 ` Marin David Condic
2001-09-04 14:15         ` Ted Dennison
2001-09-05  9:14           ` John McCabe
2001-09-05 14:19             ` Ted Dennison [this message]
2001-09-05 16:24               ` John McCabe
2001-09-05 18:33               ` Ehud Lamm
2001-09-06  9:36           ` Reinert Korsnes
2001-09-06 17:10             ` (elementary question) Test on type ? Pragma inline(granularity)? Warren W. Gay VE3WWG
  -- strict thread matches above, loose matches on Subject: below --
2001-09-04 17:55 (elementary question) Test on type ? Beard, Frank
2001-09-05  9:16 ` John McCabe
replies disabled

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