Re: Scope variable pattern
Re: Scope variable pattern
- Subject: Re: Scope variable pattern
- From: Erik Buck <email@hidden>
- Date: Fri, 11 May 2007 08:54:36 -0700 (PDT)
I am a very accomplished C++ programmer with more than a decade of experience writing and maintaining C++ code. I have to ask, why do you want to replace two lines of code that are explicit and intention revealing with the trick of relying on a side effect of constructor/destructor semantics that conceals the intent of the code ?
struct ScopedDoing {
ScopedDoing () { /* doing.. */ }
~ScopedDoing () { /* clean up.. */ }
};
..
<some function body>
{ ScopedDoing aScopedDoing; ...
}
..
The poor slob who has to figure out what your code does now absolutely must go look up the implementation of the ScopedDoing class in order to understand what <some function body> does.
In all seriousness, have you ever heard of the "obfuscated C contest" ? http://en.wikipedia.org/wiki/International_Obfuscated_C_Code_Contest
There is no reason to hold an obfuscated C++ contest. Have you ever seen the logic of a program implemented in a constructor so that the main function for the program looks like this:
int main(int argc, const char *argv[])
{
SomeClass anInstance;
return 0;
}
How is what you want different except in degree of obfuscation ?
I am not trying to start a language war. I use C++ daily, and I have seen lots of fast elegant easily maintained C++ code. I am just struck by the absurdity of this particular request. However, I fully agree that my perception of absurdity may be different that other people's.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden