# \[Pitch\] \`init\` accessors

**URL:** <https://forums.swift.org/t/pitch-init-accessors/64881>\
**Category:** Pitches\
**Created:** [May 8, 2023, 8:03pm UTC](https://forums.swift.org/t/pitch-init-accessors/64881 "2023-05-08T20:03:26Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![DevAndArtist](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/devandartist/32/287_2.png) [@DevAndArtist](https://forums.swift.org/u/DevAndArtist)\
**Post date:** [May 8, 2023, 9:17pm UTC](https://forums.swift.org/t/pitch-init-accessors/64881/6 "2023-05-08T21:17:42Z")

</div>

It's cool but the pitched syntax is extremely strange.

1. I would not force `newValue` bacause that's not a setter where the value changes. Personally I would prefer `value` or `initialValue` to make it clearer.

2. I really don't see why the developer has jump through these unusual syntactic grammar requirements:

```swift
struct S {
  var readMe: String

  var _x: Int

  var x: Int {
    init(newValue, initializes: _x, accesses: readMe) {
      print(readMe)
      _x = newValue
    }

    get { _x }
    set { _x = newValue }
  }
}

```

We could rather mimic the `set` accessor here.

```swift

struct S {
  var readMe: String

  var _x: Int

  var x: Int {
    init(initialValue) {
      print(readMe) // accesses
      self._x = initialValue // initializes
    }

    get { _x }
    set { _x = newValue }
  }
}

```

Just the plain `init(initialValue) { ... }` could be sufficient enough. I mean, why can't the compiler not figure out which stored properties are actually being initialized from the init accessor and which are read?

That makes the syntax much simpler and aligned. On top of that the `initializes` and `accesses` becomes fully transparent.

---

_[View the full topic](https://forums.swift.org/t/pitch-init-accessors/64881)._
