comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam@spam.com>
Subject: Re: Re-exporting primitive operations of a private type (like "-", and 'min)
Date: Wed, 02 Nov 2005 03:35:45 GMT
Date: 2005-11-02T03:35:45+00:00	[thread overview]
Message-ID: <luW9f.386$uD5.132@newsread3.news.pas.earthlink.net> (raw)
In-Reply-To: <slrndmg6ei.bmv.bogus_addy@tango.mindfuq.org>

Anonymous Coward wrote:

> That would probably work as long as the definition of Subtract does a
> type conversion explicitly on the Left and Right to the parent types.
> But what are the advantages?  Why would I define a Subtract operation
> and use a renames clause, when I can simply define a "-" operation
> directly?  

No. Subtract is defined for the parent type as a renaming of "-". Thus, calling 
Subtract is the same as calling "-".

The private type derives from the parent type after the declaration of Subtract, 
so it also has Subtract defined as a renaming of the predefined "-". It also has 
a redefined "-" that must be explicitly defined. The redefined "-" is then 
defined as a renaming of Subtract, so calling the redefined "-" is the same as 
calling Subtract, and calling Subtract is the same as calling the predefined "-".

That's kind of a mouthful, but it means the explicitly defined "-" for the 
private type is actually the predefined "-".

The advantage of this approach is that "-" remains the predefined operation for 
the type. It may also be a little shorter and easier to get right.

> The "-" operation must still be replaced, and it still has to have a
> declaration in the public part.  So in your case above, there would
> have to be a 
> 
>   function "-" (Left, Right : in Private_Distance_Type)
>     return Private_Distance_Type; 
> 
> in the public part.

Certainly. That's the only reason you'd go through all this.

-- 
Jeff Carter
"In the frozen land of Nador they were forced to
eat Robin's minstrels, and there was much rejoicing."
Monty Python & the Holy Grail
70



  reply	other threads:[~2005-11-02  3:35 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
2005-11-01  4:47         ` Jeffrey R. Carter
2005-11-01 23:43           ` Anonymous Coward
2005-11-02  3:35             ` Jeffrey R. Carter [this message]
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