News for hackers. Stuff that matters.
Re:Is reference counting slower than GC? by pjmlp on Tuesday May 24, 2016 @08:01AM (#11760812)
RAII is also possible in GC languages, just done differently.

If the language supports macros or trailing closures, you can somehow have similar approaches to RAII handle classes.

    with-database {
       // connection is only accessible here
    }
    // connection is now closed and gone

    with-file {
       // file is only accessible here
    }
    // file is now closed


    with-mutex {
       // mutex guarded resource is now visible here
    }
    // mutex is now released, regardless of possible errors


    with-native-memory {
       // able to use an OS memory block
    }
    // OS got the memory back

There are no comments on this comment yet.