News for hackers. Stuff that matters.
Re:Rule of Zero (C++) by anonymousDan on Friday November 23, 2012 @06:22PM (#4824006)
Could you expand on this a bit? I'd be interested to see an example of what you mean.
Re:Rule of Zero (C++) by zem on Friday November 23, 2012 @07:09PM (#4824114)
it's a ubiquitous pattern in ruby. this blog post uses a file open/close lifecycle manager as an example: http://yehudakatz.com/2012/01/10/javascript-needs-blocks/
Re:Rule of Zero (C++) by Evbn on Friday November 23, 2012 @11:32PM (#4824545)
That's more about coroutines than first class functions, and it is RAII, using a wrapper methodd for the actor/dtor instead of defining a class.
Re:Rule of Zero (C++) by zem on Saturday November 24, 2012 @12:25AM (#4824626)
it is not raii as i understand the term. there is no destructor involved in closing the file, there is just a function that opens the file, passes your code the handle, then closes it when you're done.
Re:Rule of Zero (C++) by bowyakka on Saturday November 24, 2012 @03:19PM (#4826324)
Doesn't this amount to the same thing ?
Re:Rule of Zero (C++) by zem on Saturday November 24, 2012 @07:59PM (#4826963)
it accomplishes the same purpose, but the filehandle gets closed explicitly, not when it goes out of scope and its destructor gets called.