1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Ada95 - Subprogram Renaming Declarations</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="RM-TOC.html">Contents</A> <A HREF="RM-0-29.html">Index</A> <A HREF="RM-8-5-3.html">Previous</A> <A HREF="RM-8-5-5.html">Next</A></P>
<HR>
<H1> 8.5.4 Subprogram Renaming Declarations</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">subprogram_renaming_declaration</FONT>
can serve as the completion of a <FONT FACE="Arial, Helvetica">subprogram_declaration</FONT>;
<A NAME="I3256"></A>such a <FONT FACE="Arial, Helvetica">renaming_declaration</FONT>
is called a <I>renaming-as-body</I>. <A NAME="I3257"></A>A <FONT FACE="Arial, Helvetica">subprogram_renaming_declaration</FONT>
that is not a completion is called a <I>renaming-as-declaration</I>,
and is used to rename a subprogram (possibly an enumeration literal)
or an entry. </DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">subprogram_renaming_declaration<A NAME="I3258"></A>
::= </FONT><A NAME="I3259"></A><FONT FACE="Arial, Helvetica">subprogram_specification</FONT> <B>renames</B> <I>callable_entity_</I><A NAME="I3260"></A><FONT FACE="Arial, Helvetica">name</FONT>;</DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3261"></A>The expected profile for the
<I>callable_entity_</I><FONT FACE="Arial, Helvetica">name</FONT> is the
profile given in the <FONT FACE="Arial, Helvetica">subprogram_specification</FONT>.
</DIV>
<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Normal"> The profile of a renaming-as-declaration shall
be mode-conformant with that of the renamed callable entity. <A NAME="I3262"></A></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5/1</FONT></DIV>
<DIV Class="Normal"> The profile of a renaming-as-body shall conform
fully to that of the declaration it completes. <A NAME="I3263"></A>If
the renaming-as-body completes that declaration before the subprogram
it declares is frozen, the profile shall be mode-conformant <A NAME="I3264"></A>with
that of the renamed callable entity and the subprogram it declares takes
its convention from the renamed subprogram; otherwise, the profile shall
be subtype-conformant with that of the renamed callable entity and the
convention of the renamed subprogram shall not be Intrinsic. <A NAME="I3265"></A>A
renaming-as-body is illegal if the declaration occurs before the subprogram
whose declaration it completes is frozen, and the renaming renames the
subprogram itself, through one or more subprogram renaming declarations,
none of whose subprograms has been frozen. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">name</FONT> that
denotes a formal parameter of the <FONT FACE="Arial, Helvetica">subprogram_specification</FONT>
is not allowed within the <I>callable_entity_</I><FONT FACE="Arial, Helvetica">name</FONT>.
</DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Normal"> A renaming-as-declaration declares a new view
of the renamed entity. The profile of this new view takes its subtypes,
parameter modes, and calling convention from the original profile of
the callable entity, while taking the formal parameter <FONT FACE="Arial, Helvetica">name</FONT>s
and <FONT FACE="Arial, Helvetica">default_expression</FONT>s from the
profile given in the <FONT FACE="Arial, Helvetica">subprogram_renaming_declaration</FONT>.
The new view is a function or procedure, never an entry. </DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>7.1/1</FONT></DIV>
<DIV Class="Normal"> For a call to a subprogram whose body is given
as a renaming-as-body, the execution of the renaming-as-body is equivalent
to the execution of a <FONT FACE="Arial, Helvetica">subprogram_body</FONT>
that simply calls the renamed subprogram with its formal parameters as
the actual parameters and, if it is a function, returns the value of
the call. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal"> For a call on a renaming of a dispatching subprogram
that is overridden, if the overriding occurred before the renaming, then
the body executed is that of the overriding declaration, even if the
overriding declaration is not visible at the place of the renaming; otherwise,
the inherited or predefined subprogram is called. </DIV>
<H4 ALIGN=CENTER>Bounded (Run-Time) Errors</H4>
<DIV Class="Paranum"><FONT SIZE=-2>8.1/1</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3266"></A><A NAME="I3267"></A>If
a subprogram directly or indirectly renames itself, then it is a bounded
error to call that subprogram. Possible consequences are that Program_Error
or Storage_Error is raised, or that the call results in infinite recursion.
</DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>11 A procedure can only be
renamed as a procedure. A function whose <FONT FACE="Arial, Helvetica">defining_designator</FONT>
is either an <FONT FACE="Arial, Helvetica">identifier</FONT> or an <FONT FACE="Arial, Helvetica">operator_symbol</FONT>
can be renamed with either an <FONT FACE="Arial, Helvetica">identifier</FONT>
or an <FONT FACE="Arial, Helvetica">operator_symbol</FONT>; for renaming
as an operator, the subprogram specification given in the <FONT FACE="Arial, Helvetica">renaming_declaration</FONT>
is subject to the rules given in <A HREF="RM-6-6.html">6.6</A> for operator
declarations. Enumeration literals can be renamed as functions; similarly,
<FONT FACE="Arial, Helvetica">attribute_reference</FONT>s that denote
functions (such as references to Succ and Pred) can be renamed as functions.
An entry can only be renamed as a procedure; the new <FONT FACE="Arial, Helvetica">name</FONT>
is only allowed to appear in contexts that allow a procedure <FONT FACE="Arial, Helvetica">name</FONT>.
An entry of a family can be renamed, but an entry family cannot be renamed
as a whole.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>12 The operators of the root
numeric types cannot be renamed because the types in the profile are
anonymous, so the corresponding specifications cannot be written; the
same holds for certain attributes, such as Pos.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>13 Calls with the new <FONT FACE="Arial, Helvetica">name</FONT>
of a renamed entry are <FONT FACE="Arial, Helvetica">procedure_call_statement</FONT>s
and are not allowed at places where the syntax requires an <FONT FACE="Arial, Helvetica">entry_call_statement</FONT>
in <FONT FACE="Arial, Helvetica">conditional_</FONT> and <FONT FACE="Arial, Helvetica">timed_entry_call</FONT>s,
nor in an <FONT FACE="Arial, Helvetica">asynchronous_select</FONT>; similarly,
the Count attribute is not available for the new <FONT FACE="Arial, Helvetica">name</FONT>.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>14 The primitiveness of a
renaming-as-declaration is determined by its profile, and by where it
occurs, as for any declaration of (a view of) a subprogram; primitiveness
is not determined by the renamed view. In order to perform a dispatching
call, the subprogram name has to denote a primitive subprogram, not a
non-primitive renaming of a primitive subprogram. </FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <I>Examples of
subprogram renaming declarations:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Examples"><TT><B>procedure</B> My_Write(C : <B>in</B> Character) <B>renames</B> Pool(K).Write; --<I> see <A HREF="RM-4-1-3.html">4.1.3</A></I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Real_Plus(Left, Right : Real ) <B>return</B> Real <B>renames</B> "+";<BR>
<B>function</B> Int_Plus (Left, Right : Integer) <B>return</B> Integer <B>renames</B> "+";</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Rouge <B>return</B> Color <B>renames</B> Red; --<I> see <A HREF="RM-3-5-1.html">3.5.1</A></I><BR>
<B>function</B> Rot <B>return</B> Color <B>renames</B> Red;<BR>
<B>function</B> Rosso <B>return</B> Color <B>renames</B> Rouge;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Next(X : Color) <B>return</B> Color <B>renames</B> Color'Succ; --<I> see <A HREF="RM-3-5-1.html">3.5.1</A></I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em"> <I>Example of a subprogram
renaming declaration with new parameter names:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> "*" (X,Y : Vector) <B>return</B> Real <B>renames</B> Dot_Product; --<I> see <A HREF="RM-6-1.html">6.1</A></I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Wide" Style="margin-bottom: 0.4em"> <I>Example of a subprogram
renaming declaration with a new default expression:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Minimum(L : Link := Head) <B>return</B> Cell <B>renames</B> Min_Cell; --<I> see <A HREF="RM-6-1.html">6.1</A></I></TT></DIV>
<HR>
<P><A HREF="RM-TOC.html">Contents</A> <A HREF="RM-0-29.html">Index</A> <A HREF="RM-8-5-3.html">Previous</A> <A HREF="RM-8-5-5.html">Next</A> <A HREF="RM-TTL.html">Legal</A></P>
</BODY>
</HTML>
|