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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, LOTS_OF_MONEY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ac5c3bc59168d76 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Subprogram Renaming Date: 1996/04/10 Message-ID: #1/1 X-Deja-AN: 146638728 references: <316AEA8D.7600@csehp3.mdc.com> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-04-10T00:00:00+00:00 List-Id: In article <316AEA8D.7600@csehp3.mdc.com>, James A. Squire 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. :-(