Language Change Specification for Function Knows Vector Size
LCS Number: |
LCS-2016-072b |
Version: |
2 |
Date: |
19-Mar-2017 |
Status: |
Voting |
Authors: |
Kevin Jennings, Martin Zabel, Jim Lewis, Patrick Lehmann, and Rob Gaddi |
Source Doc: |
FunctionKnowsVectorSize |
Derived from and conflicts with: |
LCS_2016_072 LCS_2016_072b |
Voting Results: Cast your votes here
Yes:
1.
Rob Gaddi - 2017-03-21 ver 2
2.
Kevin Jennings -- Mar 22, 2017 Ver 2 -- I'm for whichever version (72, 72b, 72c) that passes.
No:
Abstain:
1.
Jim Lewis- 2017-03-22 In concept I support this. Have not had time yet to review the particulars
Revision History
Revision 15:
- Branched off of Jim's 072b, differs again in page 20.
- This is revision/branch of LCS_2016_72 written by Kevin Jennings and Martin Zabel
- It only differs by the text of the added paragraph on page 20 to address issues
Revision 14: Jim's work
Revision 13: Kevin and Martin's work
Style Notes
Changes are shown in red font.
Deletions are crossed out.
Editing notes in green font.
Reviewing Notes
function TO_UNSIGNED(x : natural) return tgt : unsigned is
begin
tgt := TO_UNSIGNED(x, tgt'length);
return tgt;
end function TO_UNSIGNED;
function TO_SIGNED(x : integer) return tgt : signed is
begin
return TO_SIGNED(x, tgt'length);
end function TO_SIGNED;
Details of Language Change
LRM 4.2.1 General (Subprogram declarations)
Page 19 near bottom
function_specification ::=
[ pure | impure ] function designator
subprogram_header
[ [ parameter ] ( formal_parameter_list ) ] return [ return_identifier : ] type_mark
Page 20 edit first paragraph
The specification of a procedure specifies its designator, its generics (if any), and its formal parameters (if any). The specification of a function specifies its designator, its generics (if any), its formal parameters (if any),
its return identifier (if any),
the subtype of the returned value (the result subtype), and whether or not the function is pure. A function is impure if its specification contains the reserved word impure; otherwise, it is said to be pure. A procedure designator is always an identifier. A function designator is either an identifier or an operator symbol. A designator that is an operator symbol is used for the overloading of an operator (see 4.5.2). The sequence of characters represented by an operator symbol shall be an operator belonging to one of the classes of operators defined in 9.2. Extra spaces are not allowed in an operator symbol, and the case of letters is not significant.
Page 20 Add after the first paragraph
The return identifier of a function declaration creates an implicit variable declaration, the name of which is the return identifier and the subtype of which (T) is determined by the context of the function call. The initial value of the variable is equal to T'LEFT. This implicit declaration is the first declaration in the subprogram declarative part of the function and can be referenced in later explicit declarations.
The subtype of the return identifier can be determined in the following contexts:
a) If the function call is an expression following the assignment symbol ":=" in a constant, variable, or signal declaration, then the subtype of the return variable shall be subtype of the corresponding object declaration.
b) If the function call is the value expression in an assignment statement where the target is a declared object (or a member thereof), then the subtype of the return variable shall be the subtype of the target of the assignment.
c) If the function call is the actual in an association element, then the subtype of the return variable shall be the subtype of the corresponding formal.
d) If the function call is the formal in an association element, then the subtype of the return variable shall be the subtype of the corresponding actual.
e) If the function call is the operand of a qualified expression, then the subtype of the return variable shall be the subtype defined by the type mark of the qualified expression.
In any of these cases, it is an error if the subtype of the return variable is an unconstrained or a partially constrained composite subtype.
Page 20 Add at the end
NOTE 4 -- While the return variable of a function with a return identifier can be assigned to, this does not serve as mechanism to provide the result of the function. Once the return variable is created, it is entirely without connection to the result of the function. It is legal to explicitly return the value of the return variable.
6.5.4 Interface subprogram declarations
Page 76 near bottom of page and page 489 near middle of the page
interface_function_specification ::=
[ pure | impure ] function designator
[ [ parameter ] ( formal_parameter_list ) ] return [ return_identifier : ] type_mark
Annex C (informative) Syntax summary
Page 487 middle
[§ 4.2.1]
function_specification ::=
[ pure | impure ] function designator
subprogram_header
[ [ parameter ] ( formal_parameter_list ) ] return [ return_identifier : ] type_mark
Page 489 middle
interface_function_specification ::= [§ 6.5.4]
[ pure | impure ] function designator
[ [ parameter ] ( formal_parameter_list ) ] return [ return_identifier : ] type_mark
Comments