comp.lang.ada
 help / color / mirror / Atom feed
From: Anonymous Coward <bogus_addy@bogus_domain.net>
Subject: Re: Re-exporting primitive operations of a private type (like "-", and 'min)
Date: Tue, 01 Nov 2005 03:39:49 GMT
Date: 2005-11-01T03:39:49+00:00	[thread overview]
Message-ID: <slrndmdvss.gc.bogus_addy@tango.mindfuq.org> (raw)
In-Reply-To: iDi9f.3949$yX2.741@newsread2.news.pas.earthlink.net

In article <iDi9f.3949$yX2.741@newsread2.news.pas.earthlink.net>, 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?



  reply	other threads:[~2005-11-01  3:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-29 21:19 Re-exporting primitive operations of a private type (like "-", and 'min) Anonymous Coward
2005-10-30  8:57 ` Dmitry A. Kazakov
2005-10-30  9:18 ` Jeffrey R. Carter
2005-10-30 14:16   ` Martin Krischik
2005-10-30 22:35     ` Robert A Duff
2005-10-31  4:15   ` Anonymous Coward
2005-10-31  4:34     ` Anonymous Coward
2005-10-31  6:14     ` Jeffrey R. Carter
2005-11-01  3:39       ` Anonymous Coward [this message]
2005-11-01  4:47         ` Jeffrey R. Carter
2005-11-01 23:43           ` Anonymous Coward
2005-11-02  3:35             ` Jeffrey R. Carter
2005-11-01 14:11         ` Robert A Duff
2005-10-31  8:27     ` Niklas Holsti
2005-10-31  9:18       ` Dmitry A. Kazakov
2005-11-02  9:50       ` Jean-Pierre Rosen
2005-11-03  9:15         ` Niklas Holsti
replies disabled

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