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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7936408ed8296efa X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-19 06:00:14 PST Path: supernews.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!titan03.ksc.nasa.gov!niven.ksc.nasa.gov!usenet From: "Samuel T. Harris" Newsgroups: comp.lang.ada Subject: Re: User define attributes Date: Thu, 19 Apr 2001 07:50:31 -0500 Organization: Raytheon Aerospace Engineering Services Message-ID: <3ADEDF17.A989880A@gsde.hou.us.ray.com> References: <3ADDFE24.9B3E1038@gsde.hou.us.ray.com> <3ADE40C8.BADBA9C2@acm.org> Reply-To: samuel_t_harris@raytheon.com NNTP-Posting-Host: sstf-fw.jsc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (X11; U; IRIX64 6.2 IP19) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:6996 Date: 2001-04-19T07:50:31-05:00 List-Id: 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!"