From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Roman V. Shaposhnick" To: 9fans@cse.psu.edu Subject: Re: [9fans] how to avoid a memset() optimization Message-ID: <20021119103808.B13548@unicorn.math.spbu.ru> References: <38aa463bafe23035decff6b0364f7553@plan9.bell-labs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <38aa463bafe23035decff6b0364f7553@plan9.bell-labs.com> Date: Tue, 19 Nov 2002 10:38:08 +0300 Topicbox-Message-UUID: 23dfe944-eacb-11e9-9e20-41e7f4b1d025 On Thu, Nov 14, 2002 at 11:47:11AM -0500, presotto@plan9.bell-labs.com wrote: > Our waserror()/nexterror() stuff completely > blew away optimizing compilers since they are essentially longjumps. ........ > My three main conclusions from this were: > 1) waserror/nexterror is definitely evil unless understood by the > compiler and perhaps even then. It's a step outside the language > definition and therefore a dangerous step to take. We were > comfortable with it in Plan 9 because we controlled the compilers > but it became tortuous when someone else controlled them. That's a very interesting remark, since I've always wondered why don't you use waserror()/nexterror() in the rest of the Plan9 source tree as a regular error handling mechanism. Personally I'm still struggling with developing an error handling policy that I'd feel comfortable with. Of course, good old: if ((a = do_it()) == BadThingHappened) return TellEmAboutIt; works, but costs a little bit too much when clarity is needed. Especially when a "transaction" like pattern is needed ( e.g. I need to to have o1 = f1(); o2 = f2(); o3 = f3(); but if any of f* fails, I have to destroy what I've got so far ). C++ style exceptions are nice, but easily abused, and I haven't seen any way of emulating then in pure C. So, what your experience has been with error handling ( granted, you must've had plenty ;-) ) and what would you consider the most comfortable one ? Thanks, Roman.