comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Subprogram Renaming
Date: 1996/04/10
Date: 1996-04-10T00:00:00+00:00	[thread overview]
Message-ID: <DpMFp6.CrC@world.std.com> (raw)
In-Reply-To: 316AEA8D.7600@csehp3.mdc.com

In article <316AEA8D.7600@csehp3.mdc.com>,
James A. Squire <m193884@CSEHP3.MDC.COM> wrote:
>Still (!) Nobody has answered the $64,000.00 question:  WHY IS THIS SUCH
>A GOOD THING?

It's not SUCH A GOOD THING IN ALL CAPS.  It's just a minor short-hand.
No big deal.  You seem to be expecting some AMAZING NEW CAPABILITY --
but all you get is a shorthand notation.

>...  In other words, why did they waste their time adding this
>ability to rename a subprogram body.  Why should I do:
>
>package q is
>  procedure j;
>end q;
>
>package body q is
>  procedure k;
>  procedure j renames k;
>end q;
>
>when I can do:
>
>package q is
>  procedure k;
>end q;
>
>package body q is
>  procedure k is ...
>end q;

Well, what if K were in another package, and you want the implementation
of J to just call K?  In Ada 83, you have to write "procedure j(...) is
begin k(...); end j;", whereas in Ada 95 you can write "procedure j(
renames K;".  Nobody is saying this is some amazing wonderfulness.  It's
just a shorthand notation that seems nice in some situations.

>Now that I KNOW I can do in Ada83.  Since the parameter spec has to
>match exactly, I see no point to doing a rename in the body and hiding
>it from the user.  All you are changing is the name it goes by.  What's
>the point?

The point is layering one abstraction on top of another, where *some*
subprograms don't actually do anything, except pass the buck to another
lower-level subprogram.  Usually the *other* subprogram is in another
package -- unlike your example, which renames a subprogram from the
*same* package, which, as you noted, is rather silly.

>> As Robert Dewar said, this has nothing to do with syntax rules -- the
>> syntax for renamings is the same.  The difference is where they're
>> allowed, and what they mean.  To find the rules, you have to look at the
>> text under subprogram renamings (as opposed to just looking at the BNF
>> syntax rules).
>
>I read those - 8.5.4 and 6.3.1.  What does "subtype of the profile"
>mean?

I guess you're referring to 6.3.1(17).  It just mean the subtypes of the
parameters of whatever subprogram you're talking about.  If you want to
use renaming-as-body, you have to have matching parameter subtypes.
This rule is stricter than the "normal" (Ada 83) renaming rules for
renaming-as-declaration.

- Bob

P.S. I don't blame you for being confused.  These rules are written in a
rather language-lawyerly fashion.  :-(




  parent reply	other threads:[~1996-04-10  0:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <md5:FE4AB546A8392541EDC1E3FE12E3D8AF>
1996-04-09  0:00 ` Subprogram Renaming James A. Squire
1996-04-09  0:00   ` Robert Dewar
1996-04-10  0:00   ` Robert A Duff [this message]
1996-04-11  0:00   ` Mark A Biggar
1996-04-10  0:00 ` johndoe
1996-04-10  0:00   ` Norman H. Cohen
1996-04-11  0:00     ` Norman H. Cohen
1996-04-12  0:00       ` Jonas Nygren
1996-04-12  0:00         ` Norman H. Cohen
1996-04-13  0:00           ` Robert A Duff
1996-04-15  0:00             ` Norman H. Cohen
     [not found] <md5:3CC2294B6049DDBD8790280EABCEDE81>
1996-04-12  0:00 ` James A. Squire
     [not found] <md5:95D854EBD1A47E0E86027A3CC7DBD9A4>
1996-04-10  0:00 ` James A. Squire
1996-04-10  0:00   ` Robert Dewar
1996-04-11  0:00     ` Jonas Nygren
1996-04-11  0:00       ` Robert Dewar
1996-04-12  0:00         ` Jonas Nygren
1996-04-10  0:00   ` Robert A Duff
1996-04-11  0:00     ` Adam Beneschan
1996-04-11  0:00       ` Robert A Duff
1996-04-11  0:00       ` Robert Dewar
1996-04-10  0:00 ` johndoe
     [not found] <md5:87494FB95037B9578F62831DE10B6BB3>
1996-04-10  0:00 ` James A. Squire
     [not found] <md5:88A5E8822105A2023A0A951BB5EC646E>
1996-04-10  0:00 ` James A. Squire
     [not found] <md5:046A59600C3FEFC327385C3E914D6997>
1996-04-08  0:00 ` James A. Squire
1996-04-08  0:00   ` Robert Dewar
1996-04-09  0:00     ` Gary McKee
1996-04-09  0:00   ` Robert A Duff
     [not found] <md5:C24D8C2EE138D9627FB8B93E2E35D9F3>
1996-04-05  0:00 ` James A. Squire
1996-04-06  0:00   ` Robert Dewar
replies disabled

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