Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #15343
| From | nick_keighley_nospam@hotmail.com |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Terminology - RAII vs. Scope Guard vs...? |
| Date | 2012-04-13 00:14 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <16704739.786.1334301262058.JavaMail.geo-discussion-forums@vbab2> (permalink) |
| References | <2b96be9d-1925-4455-b6f9-12b2b15ebfad@x17g2000yqj.googlegroups.com> <2afef88f-f05f-4eb7-929b-fb587f674c68@er9g2000vbb.googlegroups.com> <9164b5b9-0424-4acf-9d2f-1344db90b3a7@w5g2000vbv.googlegroups.com> |
On Wednesday, April 11, 2012 5:10:39 PM UTC+1, Noah Roberts wrote: > On Apr 10, 2:36 pm, Joshua Maurice <joshuamaur...@gmail.com> wrote: > > On Apr 10, 1:47 pm, Noah Roberts <roberts.n...@gmail.com> wrote: > > > So RAII is when you make it so that the acquisition of a resource is > > > tied to the initialization of a scope-based variable that cleans up > > > said resource when it's destroyed. I'd have skipped the "scope-based" bit > > RAII is more than that. It's the way of coding in which you ensure > > that all resources > > 1- have an owner whose destructor will free the resource, or > > 2- be on the stack (or a global or some other "root" of the ownership > > tree). > > > > In other words, RAII is the way of coding in which at every step of > > the program, if you have a resource that needs to be freed, you can > > identify an object whose destructor will free it, or the resource is > > an object on the stack (or a global, etc.). sounds a good defintion > > This all assumes, of course, that you have a cycle-free ownership > > graph. This works amazingly well for almost all cases. Sure, you can > > invent some corner cases where this ownership tree approach isn't a > > good option, but that's beside the point. RAII is the default for > > writing good code. > > > > Scope Guards are mere utility classes to help facilitate writing in > > the RAII style. yes > Well, I'd disagree with you on that and so does most if not all of the > documentation on the subject; I think you're reading that documentation in an odd manner > all that I've seen at any rate. It is > true that using the RAII idiom as policy is a good policy decision, at > least in my opinion (not everyone's), who disagrees? > but it's still an idiom rather > than a philosophy. what's the difference between and idiom, a policy and a philosophy. You threw the "philosophy" in no one had mentioned it up to now. > It can form a part of a philosophic framework though. it guides my moral decisions? > http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread
Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-10 13:47 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Joshua Maurice <joshuamaurice@gmail.com> - 2012-04-10 14:36 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-11 09:10 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Joshua Maurice <joshuamaurice@gmail.com> - 2012-04-11 12:28 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-11 13:29 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Rui Maciel <rui.maciel@gmail.com> - 2012-04-12 02:29 +0100
Re: Terminology - RAII vs. Scope Guard vs...? Joshua Maurice <joshuamaurice@gmail.com> - 2012-04-12 14:31 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-12 16:48 -0700
Re: Terminology - RAII vs. Scope Guard vs...? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-04-13 02:34 +0200
Re: Terminology - RAII vs. Scope Guard vs...? Miles Bader <miles@gnu.org> - 2012-04-13 10:57 +0900
Re: Terminology - RAII vs. Scope Guard vs...? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-04-13 09:52 +0200
Re: Terminology - RAII vs. Scope Guard vs...? Rui Maciel <rui.maciel@gmail.com> - 2012-04-13 10:48 +0100
Re: Terminology - RAII vs. Scope Guard vs...? Miles Bader <miles@gnu.org> - 2012-04-13 22:18 +0900
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-13 09:21 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-04-11 21:36 +0000
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-11 16:07 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Juha Nieminen <nospam@thanks.invalid> - 2012-04-12 06:10 +0000
Re: Terminology - RAII vs. Scope Guard vs...? Gareth Owen <gwowen@gmail.com> - 2012-04-12 18:18 +0100
Re: Terminology - RAII vs. Scope Guard vs...? Juha Nieminen <nospam@thanks.invalid> - 2012-04-13 04:52 +0000
Re: Terminology - RAII vs. Scope Guard vs...? Gareth Owen <gwowen@gmail.com> - 2012-04-13 06:59 +0100
Never using free() or realloc(). Destroying heaps. @Jeff-Relf.Me - 2012-04-13 00:55 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Rui Maciel <rui.maciel@gmail.com> - 2012-04-11 21:28 +0100
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-11 13:40 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Rui Maciel <rui.maciel@gmail.com> - 2012-04-12 02:27 +0100
Re: Terminology - RAII vs. Scope Guard vs...? scott@slp53.sl.home (Scott Lurndal) - 2012-04-12 17:25 +0000
Re: Terminology - RAII vs. Scope Guard vs...? Gareth Owen <gwowen@gmail.com> - 2012-04-12 19:21 +0100
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-12 16:38 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Rui Maciel <rui.maciel@gmail.com> - 2012-04-13 11:02 +0100
Re: Terminology - RAII vs. Scope Guard vs...? nick_keighley_nospam@hotmail.com - 2012-04-13 00:29 -0700
Re: Terminology - RAII vs. Scope Guard vs...? nick_keighley_nospam@hotmail.com - 2012-04-13 00:14 -0700
csiph-web