Skip to content

[WIP] Refactor function builders to rewriting statements #27713

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

Closed

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Oct 16, 2019

Refactor the implementation of function builders so they maintain the statement structure of the closure/function body to which they are applied. This replaces the previous "fold everything into a single expression" implementation with one that is better in several regards:

  • It matches better with the evolving function builder proposal/pitch document, which describes the transformation as introducing intermediate local variables to capture the results of each buildBlock/buildExpression/buildIf/etc. invocation. The result is easier to reason about.
  • It allows generalization to statement kinds that cannot be expressed in a single expression, e.g., if let, although each of these will require work.
  • It charts a path toward a more usable model for type checking multi-statement closures

@DougGregor DougGregor force-pushed the function-builders-generalization branch from 06817af to 9d18cc7 Compare October 30, 2019 00:04
@DougGregor DougGregor changed the title WIP function builders generalization [WIP] Refactor function builders to rewriting statements Oct 30, 2019
@DougGregor DougGregor requested review from hborla and xedin October 30, 2019 15:50
@DougGregor
Copy link
Member Author

This is incomplete, because it doesn't handle function builders being applied to functions/properties. However, this is the intended direction, and I'd like to get some review on the general structure.

…ons.

The constraint system's support for function builders was limited to closure
expressions. Generalize this support to work with arbitrary functions, as a
precursor to handling application of function builders to functions via the
same mechanism.
Handles the case of, e.g., `@ViewBuilder var body: some View { ... }`.
@DougGregor
Copy link
Member Author

Everything here has been subsumed by #29133

@DougGregor DougGregor closed this Jan 15, 2020
@DougGregor DougGregor deleted the function-builders-generalization branch January 15, 2020 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant