Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!mephisto!mcnc!decvax.dec.com!zinn!nuucp From: mjv@objects.mv.com (Michael J. Vilot) Newsgroups: comp.lang.c++ Subject: Re: C++ coding standards (Comment needed) Message-ID: <883@zinn.MV.COM> Date: 23 Aug 90 23:44:05 GMT Sender: nuucp@zinn.MV.COM Lines: 39 Roger Scott mentions: > I wouldn't mind the ability to un-declare a variable after I am "done" I use blocks to achieve this effect. I also rely more on expressions and less on explicit intermediate variables. I sometimes use objects of classes that only provide constructors and destructors. I use them only for their side-effects. Here's a simple example: class Timer { time_t start; public: Timer(); // records start ~Timer(); // computes elapsed, displays it on cerr }; void f() { // do some work { Timer t; // do some timed work, and report the time at block exit } // etc. } The Timer object `t' is only active in the inner block. Of course, the object is apparently never used, so I may get into trouble with those building aggressively-optimizing compilers. I hope such optimizations allow this use of constructor/destructor side-effects. -- Mike Vilot, ObjectWare Inc, Nashua NH mjv@objects.mv.com (UUCP: ...!decvax!zinn!objects!mjv)