CVS difference for ai12s/ai12-0190-1.txt
--- ai12s/ai12-0190-1.txt 2016/12/28 04:20:39 1.5
+++ ai12s/ai12-0190-1.txt 2018/03/02 03:17:49 1.6
@@ -1,4 +1,4 @@
-!standard 5.5.2(2/3) 16-10-12 AI12-0190-1/03
+!standard 5.5.2(2/3) 18-02-28 AI12-0190-1/04
!class Amendment 16-06-02
!status work item 16-06-02
!status received 16-05-06
@@ -8,7 +8,10 @@
!summary
Provide an ability to construct a local anonymous function at the point
-of a call on a subprogram that has an access-to-function parameter.
+of a call on a subprogram that has an access-to-function parameter,
+or in an instantiation with a formal subprogram parameter, or other
+contexts where the expected type is an access-to-function type,
+or there is an expected profile for a function.
!problem
@@ -53,7 +56,63 @@
!wording
-** TBD.
+Replace 4.4(7/3) with:
+
+ primary ::=
+ numeric_literal | null | string_literal | aggregate
+ | name | allocator | (expression)
+ | (conditional_expression) | (quantified_expression)
+ | function_expression
+
+Add section after 4.5.8:
+
+ 4.5.9 Function Expressions
+
+ Function expressions provide a way to define a function at a point
+ where an access-to-function type is the expected type, or in a generic
+ instantiation as an actual parameter corresponding to a formal subprogram
+ parameter.
+
+ Syntax
+
+ function_expression ::=
+ (FUNCTION [function_formal_parameter_list] RETURN expression)
+
+ function_formal_parameter_list ::=
+ formal_part | (identifier {, identifier})
+
+ Name Resolution
+
+ In a context where there is an expected type rather than an expected
+ profile for a function_expression, the expected type shall be a single
+ access-to-function type, and the profile of this type is considered
+ the expected profile for the function_expression. The result type of
+ the expected profile of the function_expression is the expected type
+ for the expression of the function_expression. If there is no
+ function_formal_parameter_list, the expected profile shall have no
+ parameters. If the function_formal_parameter_list is a formal_part,
+ then it shall be subtype conformant to the expected profile if there
+ is an expected type, or merely mode conformant otherwise. If the
+ function_formal_parameter_list is a sequence of identifiers, the
+ number of identifiers in the sequence shall be the same as the number
+ of formal parameters in the expected profile.
+
+ Static Semantics
+
+ A function_expression used in a context where there is an expected
+ type is equivalent to a local expression_function_declaration (see
+ 6.8), with the function_expression replaced by an Access
+ attribute_reference of this locally defined function; otherwise, the
+ function_expression is equivalent to such a local declaration with the
+ function_expression replaced by a name denoting this locally defined
+ function. The profile of this locally defined function has a result
+ type determined by the expected profile, and a formal part determined
+ by the formal_part, if provided in the expression_function, or by the
+ formal part of the expected profile otherwise, but with the name of
+ each formal parameter of the expected profile replaced by the
+ corresponding identifier in the sequence of identifiers. The expression
+ of this locally defined expression function is that of the
+ function_expression.
!discussion
@@ -1742,5 +1801,13 @@
and if anybody wants a name for the lambda:
function ParisMatch(X : String) return Boolean is Filter("Paris");
+
+****************************************************************
+
+From: Tucker Taft
+Sent: Tuesday, February 27, 2018 6:32 PM
+
+I have added wording to this AI on "function expressions". [This is version
+/04 of the AI - ED.]
****************************************************************
Questions? Ask the ACAA Technical Agent