comp.lang.ada
 help / color / mirror / Atom feed
From: "Samuel T. Harris" <u61783@gsde.hou.us.ray.com>
Subject: Re: User define attributes
Date: Thu, 19 Apr 2001 07:50:31 -0500
Date: 2001-04-19T07:50:31-05:00	[thread overview]
Message-ID: <3ADEDF17.A989880A@gsde.hou.us.ray.com> (raw)
In-Reply-To: 3ADE40C8.BADBA9C2@acm.org

Jeffrey Carter wrote:
> 
> "Samuel T. Harris" wrote:
> >
> >     generic
> >         type Index_Type is (<>);
> >         type Component_Type is private;
> >         type Array_Type is array (Index_Type range <>) of Component_Type;
> >         with function Width (Item : Index_Type) return Natural is <>;
> >         with function Image (Item : Index_Type) return String is <>;
> >         with function Value (Item : String) return Index_Type is <>;
> 
> Note that since Index_Type is a discrete type, the generic can call
> Index_Type'Image, Index_Type'Value, and so on directly.
> 

Reread my post. I address that issue. Width cannot be assumed,
due to the other kinds of generics I have written (like
address_attribute_functions) so it must be "functionized"
in certain places, so I functionize it in all places.
Similarly for image and value. It is there for the sake
on consistency.

Besides, I may want to instantiate this generic with something
other than the attribute functions or their equivalent.
I might want some particular format, even for integers
or floats (like say using base 16 instead of base 10).

My general rule on generics is pass in all functionality and
default then to "is <>". This includes numerics. Generics
involving numeric types should pass in all the operators.
This notion is especially important when one considers
that limited private types with a new equality operator
defined will revert back to the default equality
in generic instantiations. Better to pass that "=" in.
Since these are usually defaulted for me, I don't
both providing in the generic instantiation. I only
have to bother with ensuring they are visible with
appropriate use clauses.

-- 
Samuel T. Harris, Principal Engineer
Raytheon, Aerospace Engineering Services
"If you can make it, We can fake it!"



  reply	other threads:[~2001-04-19 12:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-14 13:33 User define attributes Ayende Rahien
2001-04-16  7:27 ` Martin Dowie
2001-04-16 11:23   ` Ayende Rahien
2001-04-16 11:37     ` Martin Dowie
2001-04-16 14:35       ` Samuel T. Harris
2001-04-16 15:20         ` Martin Dowie
2001-04-16 15:37           ` Brian Rogoff
2001-04-16 16:19           ` Samuel T. Harris
2001-04-16 17:08             ` Marin David Condic
2001-04-16 22:00               ` Samuel T. Harris
2001-04-17 12:34                 ` Georg Bauhaus
2001-04-17 20:35                   ` Samuel T. Harris
2001-04-24 21:00                   ` Samuel T. Harris
2001-04-16 17:37             ` Martin Dowie
     [not found]           ` <0tEC6.7646$FY5.638172@www.newsranger.com>
2001-04-16 17:34             ` Martin Dowie
2001-04-18 12:14         ` Marius Amado Alves
2001-04-18 20:50           ` Samuel T. Harris
2001-04-19  1:35             ` Jeffrey Carter
2001-04-19 12:50               ` Samuel T. Harris [this message]
2001-04-20 19:08             ` Marius Amado Alves
replies disabled

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