# \[Accepted\] SE-0390: Noncopyable structs and enums

**URL:** <https://forums.swift.org/t/accepted-se-0390-noncopyable-structs-and-enums/65157>\
**Category:** Announcements\
**Created:** [May 23, 2023, 7:53pm UTC](https://forums.swift.org/t/accepted-se-0390-noncopyable-structs-and-enums/65157 "2023-05-23T19:53:04Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Andrew\_Trick](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/andrew_trick/32/323_2.png) [@Andrew\_Trick](https://forums.swift.org/u/Andrew_Trick)\
**Post date:** [May 15, 2024, 5:49pm UTC](https://forums.swift.org/t/accepted-se-0390-noncopyable-structs-and-enums/65157/21 "2024-05-15T17:49:46Z")

</div>

@Joe_Groff @Michael_Gottesman @kavon I've posted an [update to SE-0390: Noncopyable structs and enums; Deinitialization #2432](https://github.com/apple/swift-evolution/pull/2432/commits/4732446a481c02d1081a7fb62eeea313ac9e53f8). The proposal was accepted, but a few people noticed incorrect wording in the definition of strict lifetimes for noncopyable types. This update makes the proposal consistent with the implementation and with what was discussed in the this review thread. In the process, I clarified the related example. I renamed the example's noncopyable struct to `File` because current and future `FileDescriptor` types will likely be copyable.

---

<div class="post-metadata">

**Author:** ![7ombie](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/7ombie/32/36317_2.png) [@7ombie](https://forums.swift.org/u/7ombie)\
**Post date:** [September 10, 2024, 7:56pm UTC](https://forums.swift.org/t/accepted-se-0390-noncopyable-structs-and-enums/65157/22 "2024-09-10T19:56:19Z")

</div>

Personally, I call it the _sans operator_, and pronounce `~Copyable` as _sans Copyable_, using _sans_ to mean _without implying conformance to_.

* * *

@Andrew_Trick - In the proposal, there's a code example that confused me:

```swift
struct FileDescriptor: ~Copyable {
  private var fd: Int32

  init(fd: Int32) { self.fd = fd }

  func write(buffer: Data) {
    buffer.withUnsafeBytes { 
      write(fd, $0.baseAddress!, $0.count)
    }
  }

  deinit {
    close(fd)
  }
}

```

Presumably, the line `write(fd, $0.baseAddress!, $0.count)` would call `self.write`, but the signature is wrong.

I understand it's just example code, but wondered if I misunderstood something??

---

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [September 10, 2024, 9:13pm UTC](https://forums.swift.org/t/accepted-se-0390-noncopyable-structs-and-enums/65157/23 "2024-09-10T21:13:26Z")

</div>

> [@7ombie](#):
>
> I understand it's just example code, but wondered if I misunderstood something??

It’s calling [write(2)](https://man.freebsd.org/cgi/man.cgi?write(2))

---

<div class="post-metadata">

**Author:** ![7ombie](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/7ombie/32/36317_2.png) [@7ombie](https://forums.swift.org/u/7ombie)\
**Post date:** [September 10, 2024, 10:42pm UTC](https://forums.swift.org/t/accepted-se-0390-noncopyable-structs-and-enums/65157/24 "2024-09-10T22:42:00Z")

</div>

Oh, I see now. Thank you, @Slava_Pestov.

I was thinking it would call `self.write` because `self` has a member called `write`, as if it matched the name first (to methods of that name), then matched the signature (to the correct overload from amongst them). I don't know why I thought that.

Thanks again.

---

<div class="post-metadata">

**Author:** ![allevato](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/allevato/32/385_2.png) [@allevato](https://forums.swift.org/u/allevato)\
**Post date:** [September 10, 2024, 11:21pm UTC](https://forums.swift.org/t/accepted-se-0390-noncopyable-structs-and-enums/65157/25 "2024-09-10T23:21:05Z")

</div>

> [@7ombie](#):
>
> I was thinking it would call `self.write` because `self` has a member called `write`, as if it matched the name first (to methods of that name), then matched the signature (to the correct overload from amongst them). I don't know why I thought that.

That actually is how overload resolution works today, more or less—once the member with that basename is found, I think it stops searching. The code in that snippet won't compile without an explicit `Darwin.`/`Glibc.` qualifier to explicitly request the global function: [Compiler Explorer](https://godbolt.org/z/PTo1qc5bv)

---

<div class="post-metadata">

**Author:** ![7ombie](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/7ombie/32/36317_2.png) [@7ombie](https://forums.swift.org/u/7ombie)\
**Post date:** [September 20, 2024, 8:52pm UTC](https://forums.swift.org/t/accepted-se-0390-noncopyable-structs-and-enums/65157/26 "2024-09-20T20:52:41Z")

</div>

Ahh. Thank you, @allevato. I appreciate the clarification.

[Previous page](https://forums.swift.org/t/accepted-se-0390-noncopyable-structs-and-enums/65157.md?page=1)
