Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Thu, 12 Apr 2012 12:18:12 -0500 From: Gareth Owen Newsgroups: comp.lang.c++ Subject: Re: Terminology - RAII vs. Scope Guard vs...? 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> <4f8671dd$0$3116$7b1e8fa0@news.nbl.fi> Date: Thu, 12 Apr 2012 18:18:11 +0100 Message-ID: <87ehrszx64.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:1sEnCU8q6NJJDwhjWz4MOSD2uRc= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 26 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-RutmeDybnSTdSE+u1DX07cWTnnxc3K9p57mgQV3xuPvTGg/D36i7rGO0xL7Qcds1yhyKAdB+Ss6gn4u!sOiSPvpeKX8ZS/hZ4vDG3rAwgiUbBDY3H1fERD1ed6+vNWoB4fK1HDcG5DIPhx9w0PU= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2578 Xref: csiph.com comp.lang.c++:15324 Juha Nieminen writes: > The wikipedia page also seems to assume that RAII is just about scope-based > construction and destruction of objects, as indicated for example by giving > the gcc extension "cleanup" variable attribute as an example on how to > emulate RAII in C. However, it's not just about construction and destruction > of objects. One extremely important part of RAII is copying (both in the > form of copy constructors and assignment operators). I don't think that's an unreasonable distinction. Clearly, copying semantics have to be well defined for any RAII-like resource-management-through-ownership idiom/scheme/philosophy to work, but you don't need C++ copy/assignment. You could define * a language that forces copyable object to have a java-like user-provided clone() for all objects, and no implicit copying or assignment for user defined types (just as many C++ polymorphic classes do) * or a language where every object acted like std::shared_ptr * or even (god forbid) a language where every object acted like std::auto_ptr and still have RAII, just as long as you had destruction when the last reference vanished.