comp.lang.ada
 help / color / mirror / Atom feed
From: "W. Wesley Groleau x4923" <wwgrol@pseserv3.fw.hac.com>
Subject: Re: Generics question
Date: 1997/07/22
Date: 1997-07-22T00:00:00+00:00	[thread overview]
Message-ID: <33D5320C.63E3@pseserv3.fw.hac.com> (raw)
In-Reply-To: 5r37k9$h4p$1@kelp.mbay.net


>         I have a computational algorithm that I've implemented that has
>         the (admitedly unusual) property that it is perfectly valid for either
>         arrays of Integers or arrays of Floats.    As far as I can see I
>         CANNOT make a generic version of the package that will work for
>         both, e.g.:
> 
>         Generic
>                 Type Element is <something meaning INTEGER or FLOAT subtypes>
>                 Type DataArray  is Array(Natural  Range<>) of Element;
> 
>         .....
> 
>         Is there a way to do this ?   or do I have to actually make two different copies
>         (which differ only in the definition of ELEMENT).

Does it use attributes of type Element?  If not, say
   generic
      type Element is private;
      type Data_Array is Array(Natural  Range<>) of Element;
   ....

when you try to compile, you'll get error messages about undefined
operators.  Something along the lines of "*"(Element,element)return
element is not defined.  When that happens, add

    function "*" ( L, R : Element ) return Element is <>;

to your list of formal parameters.

-- 
----------------------------------------------------------------------
    Wes Groleau, Hughes Defense Communications, Fort Wayne, IN USA
Senior Software Engineer - AFATDS                  Tool-smith Wanna-be
                    wwgrol AT pseserv3.fw.hac.com

Don't send advertisements to this domain unless asked!  All disk space
on fw.hac.com hosts belongs to either Hughes Defense Communications or 
the United States government.  Using email to store YOUR advertising 
on them is trespassing!
----------------------------------------------------------------------




  reply	other threads:[~1997-07-22  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-22  0:00 Generics question Skip Carter
1997-07-22  0:00 ` W. Wesley Groleau x4923 [this message]
1997-07-23  0:00 ` Brian Rogoff
1997-07-24  0:00   ` Michael F Brenner
1997-07-24  0:00     ` Jon S Anthony
1997-07-24  0:00     ` Brian Rogoff
1997-07-23  0:00 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1989-09-19 23:03 Generics Question Jay Labhart
replies disabled

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