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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e5bfd51af02edca2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!130.81.64.211.MISMATCH!cycny01.gnilink.net!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc08.POSTED!20ae255c!not-for-mail Newsgroups: comp.lang.ada From: Anonymous Coward Subject: Re: Re-exporting primitive operations of a private type (like "-", and 'min) References: Message-Id: User-Agent: slrn/0.9.7.4 (Linux) Date: Tue, 01 Nov 2005 03:39:49 GMT NNTP-Posting-Host: 141.149.78.234 X-Complaints-To: abuse@verizon.net X-Trace: trnddc08 1130816389 141.149.78.234 (Mon, 31 Oct 2005 22:39:49 EST) NNTP-Posting-Date: Mon, 31 Oct 2005 22:39:49 EST Xref: g2news1.google.com comp.lang.ada:6078 Date: 2005-11-01T03:39:49+00:00 List-Id: In article , Jeffrey R. Carter wrote: > Anonymous Coward wrote: > >> function Subtract (Left, Right : in Private_Distance_Type) >> return Private_Distance_Type is >> >> begin >> >> --Kazakov's suggested approach. This is good because it's >> --simple, and doesn't require type conversions. >> --(May not work with gnat 3.15p) >> >> return (Left - Right); >> >> end Subtract; > > This isn't going to work. Subtract has to be defined for the private > type's parent (as a renaming of "-"), so the private type also has > Subtract defined. Then you can define "-" for the private type as a > renaming of Subtract. > > Here, "-" refers to the explicitly defined operation, which is a > renaming of Subtract, so this is infinite recursion. You seem to be correct. The segmentation fault was probably due to running out of stack space because of an infinite recursion. I didn't suspect that at first, because I didn't get the compiler warning about infinite recursion this time, so it seems the renaming made put the flaw beyond gnats detection. So in the end, the 'base technique doesn't work either, and I'm left with type conversions that explicitly reference the parent: function "-" (Left, Right : in Private_Distance_Type) return Private_Distance_Type is begin return Private_Distance_Type(Public_Distance_Type(Left) - Public_Distance_Type(Right)); end "-"; Did someone say ADA 2005 will handle this better? When is ADA 2005 expected to roll out?