Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
zem
on Nov 24, 2012
|
parent
|
context
|
favorite
| on:
Rule of Zero (C++)
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/
Evbn
on Nov 24, 2012
[–]
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.
zem
on Nov 24, 2012
|
parent
[–]
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.
bowyakka
on Nov 24, 2012
|
root
|
parent
[–]
Doesn't this amount to the same thing ?
zem
on Nov 25, 2012
|
root
|
parent
[–]
it accomplishes the same purpose, but the filehandle gets closed explicitly, not when it goes out of scope and its destructor gets called.
Join us for
AI Startup School
this June 16-17 in San Francisco!
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: