News for hackers. Stuff that matters.
Re:Manifesto: Adding memory ownership to Swift by pjmlp on Saturday February 18, 2017 @03:50AM (#13674106)
The correct way would be to use a trailing closure.

Something like

    func fizzle() {
        lock_guard(mutex) {
           if (count_ >= 3) {return; }
           count_ = count_ + 1;
        }
    }

Where lock_guard() might be then something like this, implemented on some utility library:

    func lock_guard (_ m:Mutex, action: () -> Void) -> Void {
        m.lock();
        defer {
          m.unlock();
        }
        action();
    }
This is one of the RAII approaches in functional programming, using partial function application and higher order functions, to create new types of operations.
Re:Manifesto: Adding memory ownership to Swift by jsolson on Saturday February 18, 2017 @11:17AM (#13675246)
This is fair, and what I've done so far in Swift (with a cute little extension on NSLocking no less :).

If you're going to add moveonly types with destructors, though, it seems strongly desirable to give them (or at least making available) lexical RAII semantics.