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

SE-0400: State limitations #2389

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

AnthonyLatsis
Copy link
Contributor

@AnthonyLatsis AnthonyLatsis commented Apr 4, 2024

@AnthonyLatsis
Copy link
Contributor Author

@hborla ping

@rjmccall rjmccall added content change Content change to an existing document LSG Contains topics under the domain of the Language Steering Group labels Apr 22, 2024
## Source compatibility

`init` accessors are an additive capability with new syntax; there is no impact on existing source code.

## ABI compatibility

`init` accessors are only called from within a module, so they are not part of the module's ABI. In cases where a type's initializer is `@inlinable`, the body of an `init` accessor must also be inlinable.
`init` accessors are only called from within a source file, so they are not part of the module's ABI.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original text is correct. Even if you can only define init accessors in the primary declaration of a type, you can add an initializer in another source file that will call the init accessor:

// in FirstFile.swift

struct S {
  var _x: Int

  var x: Int {
    @storageRestrictions(initializes: _x)
    init {
      self._x = newValue
    }
    get { _x }
  }
}

// in SecondFile.swift

extension S {
  init() {
    self.x = 10
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. We had a crash report with like the simplest example of an init accessor use across files, and I was not sure if this sentence really meant they could be internal because the forum topics appeared to settle on fileprivate. I could have just inferred it from the inlinable business that follows, really. But I still think this paragraph would benefit from a little more straightforwardness and accuracy (see the latest revision).

proposals/0400-init-accessors.md Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content change Content change to an existing document LSG Contains topics under the domain of the Language Steering Group
Projects
None yet
3 participants