dabeaz,
@dabeaz@mastodon.social avatar

As far as I can tell, the primary use of RAII is to sound smart.

PeterLudemann,

@dabeaz
"Context Manager" or "'with' statement" are the preferred terminology?

dabeaz,
@dabeaz@mastodon.social avatar

@PeterLudemann I have no idea. Are we just talking about garbage collection? Or how to program?

PeterLudemann,

@dabeaz
Wikipedia says that RAII was invented by the same guy who invented C++, so ¯_(ツ)_/¯

I think it's "computers are good at keeping track of things, especially if you help them a bit (e.g., with the 'with' statement) and people are terrible at keeping track of things, so let's repurpose one thing (lifetimes of variables) as another thing (resource allocation)".

dabeaz,
@dabeaz@mastodon.social avatar

@PeterLudemann Honestly, I think my objection is not so much the thing, but the introduction of fancy terminology for the thing.

PeterLudemann,

@dabeaz
"Other names for this idiom include Constructor Acquires, Destructor Releases (CADRe) and one particular style of use is called Scope-based Resource Management (SBRM)."
https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization
Although it doesn't mention Go's "defer".

BTW, I'd like to combine Python's 'with' and 'for', e.g.:
for line with open(...):

dabeaz,
@dabeaz@mastodon.social avatar

@PeterLudemann I like both of those far better.

vy,
@vy@sciencemastodon.com avatar

@dabeaz @PeterLudemann i write some c applications that never call free because they do some work and exit

dabeaz,
@dabeaz@mastodon.social avatar

@vy @PeterLudemann Aren't you worried about what others might think?

PeterLudemann,

@vy @dabeaz
I'm sure that saves several microseconds.

vy,
@vy@sciencemastodon.com avatar

@PeterLudemann @dabeaz it's done to simplify coding and not waste time on tedious bookkeeping - when possible not to.

dabeaz,
@dabeaz@mastodon.social avatar

@vy @PeterLudemann But aren't you worried about preserving semicommutative transitivity?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • mdbf
  • ethstaker
  • magazineikmin
  • GTA5RPClips
  • rosin
  • thenastyranch
  • Youngstown
  • InstantRegret
  • slotface
  • osvaldo12
  • kavyap
  • khanakhh
  • Durango
  • megavids
  • everett
  • cisconetworking
  • normalnudes
  • tester
  • ngwrru68w68
  • cubers
  • modclub
  • tacticalgear
  • provamag3
  • Leos
  • anitta
  • JUstTest
  • lostlight
  • All magazines