News for hackers. Stuff that matters.
Re:Facebook is using D in production starting today by agwa on Friday October 11, 2013 @02:08PM (#6534809)
defer is great for "one off" cleanups, but in so many cases (closing file handles, releasing locks, etc.) cleanup is not one off but is repeated over and over again. So the price of explicitness is redundant code that is easy to forget or get wrong.

Note that if your language supports RAII and lambdas (e.g. C++11), it's trivial to implement defer using a class that takes a function as an argument to its constructor and calls that function in its destructor. So you can still have the flexibility of defer in a language with RAII.

Re:Facebook is using D in production starting today by mratzloff on Saturday October 12, 2013 @10:57AM (#6538921)
My preferred method of handling this is how Ruby does it with, e.g., File.open. The function yields the file handle and then closes it once the supplied block (think lambda function) ends. This is similar to what you refer to, but without the class. The class is useful for heap objects, of course.
Re:Facebook is using D in production starting today by Shorel on Friday October 11, 2013 @02:52PM (#6535109)
Reminds me of UNWIND-PROTECT in CL