-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C# v7.x: Local functions #104
Conversation
3baa9e8
to
21e116a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great @RexJaeschke Should we mark this ready for review?
I've got one note for how local functions interacts with generalized async return types.
I've also got one second question that won't need to be addressed until C# 8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add notes from committee meeting.
Addresses comments in committee meeting: - #104 (comment) - #104 (comment)
This is now ready for final review. @jskeet Should I tag others for review? |
A lot of the work on this feature was done by @agocke. It would be good to get his feedback. |
I'll try to take a look. It looks like the definite assignment section needs work. Unlike lambdas, local functions use a more precise definite assignment when not converted to delegates. I'll try to write up some appropriate spec language for this. Overview of the differences is at https://commentout.com/localfunc.html |
@BillWagner I think the header and modifiers rules needs tweaking: We have local_function_header
: local_function_modifiers? return_type identifier type_parameter_list?
( formal_parameter_list? ) type_parameter_constraints_clause*
;
local_function_modifiers
: 'async'
| 'unsafe'
; That allows a local function to have no modifiers, Following the corresponding pattern for modifiers on methods (14.16.1), the rule should be renamed local_function_header
: local_function_modifier* return_type identifier type_parameter_list?
( formal_parameter_list? ) type_parameter_constraints_clause*
;
local_function_modifier
: 'async'
| 'unsafe'
; |
Co-authored-by: KalleOlaviNiemitalo <kon@iki.fi>
Addresses comments in committee meeting: - #104 (comment) - #104 (comment)
In this commit, create the new clause for the definite assignment rules for local functions. Move the existing example to that clause. Add text from Andy's comments and notes.
Incorporate the rules for definite assignment for captured variables in local functions. This is both for local function calls and for delegate conversion.
Co-authored-by: Nigel-Ecma <perryresearch@zoot.net.nz>
Co-authored-by: Jon Skeet <jonskeet@google.com>
Co-authored-by: Neal Gafter <neal@gafter.com>
28f95fe
to
3a4fc3d
Compare
We resolved these two discussions during the committee meeting. Edits reflect those decisions.
@jskeet Check the final commit, and when you're ready, let's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nits left; happy for it to be merged after that.
* Update statements.md * Update unsafe-code.md * Add semantics and example for local functions v7.0 feature * removed local function unsafe grammar extension With the consolidation of the unsafe grammar in PR #233, this text is no longer needed. * include support for local functions * add support for local functions * fix build issues * Apply suggestions from code review Co-authored-by: KalleOlaviNiemitalo <kon@iki.fi> * clarify definite assignment, add examples Addresses comments in committee meeting: - dotnet/csharpstandard#104 (comment) - dotnet/csharpstandard#104 (comment) * respond to feedback. * grammar updates * Incorporate Andy's text In this commit, create the new clause for the definite assignment rules for local functions. Move the existing example to that clause. Add text from Andy's comments and notes. * finish local functions and definite assignment. Incorporate the rules for definite assignment for captured variables in local functions. This is both for local function calls and for delegate conversion. * typo * Apply suggestions from code review Co-authored-by: Nigel-Ecma <perryresearch@zoot.net.nz> * Apply suggestions from code review * Update standard/statements.md Co-authored-by: Jon Skeet <jonskeet@google.com> * Update standard/statements.md * Update standard/statements.md Co-authored-by: Neal Gafter <neal@gafter.com> * Update standard/statements.md * Update standard/statements.md * edits based on September committee meeting * fix link text * fix section renumbering issue * Final edits We resolved these two discussions during the committee meeting. Edits reflect those decisions. * updates from code review. * one more bit of feedback. Co-authored-by: Bill Wagner <wiwagn@microsoft.com> Co-authored-by: KalleOlaviNiemitalo <kon@iki.fi> Co-authored-by: Nigel-Ecma <perryresearch@zoot.net.nz> Co-authored-by: Jon Skeet <jonskeet@google.com> Co-authored-by: Neal Gafter <neal@gafter.com>
No description provided.