SE-0390: @noncopyable structs and enums

I very much support this proposal, I think I'm waiting for it for over 5 years now :slight_smile:.

I have two pieces of feedback:

  • Can we make sure that is is possible to write

    @available(*, unavailable)
    deinit { preconditionFailure("the impossible happened") }
    

    To be able to have @noncopyable types where the user is forced to call a consuming (and forgetful) function like close() async throws? Functions like close cannot be synchronous in all systems, many systems require deregistration of a file descriptor from systems like kqueue/epoll before being able to actually close the fd. Also close(2) can block so in some cases it may be wise to do so off the Swift Concurrency cooperative pool.

  • I'm not in love with reusing the word deinit for @noncopyable structs/enums. I'm sure we can find a word that makes it clearer what's going on and that it is not run when it has been forgetten before.

7 Likes