Skip to content
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

[WIP] Property behaviors #23292

Closed
wants to merge 10 commits into from

Conversation

DougGregor
Copy link
Member

A different, experimental take on property behaviors.

…ble.

When a variable has a property behavior, wrap the type of the variable in
the property behavior type. For example, a property behavior “Lazy”
should be written as Lazy<T>. A variable declared as

  var someLazyInt: Int by Lazy

will have a storage type of Lazy<Int>.
When a property behavior contains an initializer init(initialValue:), the
initial value provided to a variable using that property behavior will be
implicitly passes to the behavior’s init(initialValue:) initializer. This
allows property behavior types to opt-in to being initialized implicitly,
from a value of their stored type.
When referencing a property that has a property behavior, implicitly
reference the `value` of the behavior to see the underlying type of the
property.
Implement a very tightly-bound ^ prefix operator to access the behavior of
a property that has a behavior, suppressing the implicit “unwrap” that
looks at the underlying value.
If a property behavior’s “value” itself has a property behavior, also
implicitly unwrap that and allow suppression of any number of levels
of that implicit unwrapping with, e.g., ^(^doubleWrapped).
…rap.

The ^ binds tightly to an identifier or parenthesized expression, so after
forming the suppress-unwrap expression, parse a postfix expression
suffix (if any).
@DougGregor DougGregor added the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Mar 14, 2019
@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility release

@DougGregor
Copy link
Member Author

I'm abandoning this approach in favor of #23440

@DougGregor DougGregor closed this Mar 20, 2019
@AnthonyLatsis AnthonyLatsis removed the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Apr 18, 2023
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.

2 participants