Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 33,197 of 33,346    |
|    =?ISO-8859-1?Q?=D6=F6_Tiib?= to Kamil Rojewski    |
|    Re: Template setters    |
|    07 Sep 13 18:40:46    |
      From: ootiib@hot.ee              On Saturday, 7 September 2013 15:00:59 UTC+3, Kamil Rojewski wrote:       > Recently I was wondering about trying out a new approach to writing       > setters in classes.              Have you considered avoiding those "setters"? Setters only make it       difficult for human brain that expects a "person" to "marry" or to       "divorce" and does not expect some random spaghetti function somewhere       to "set marital status", "set spouse", "set family name" etc. instead.              > Traditional pre-C++11 approach relied on passing const & for complex       > types and value for simple ones, like int.              You seriously oversimplify that pre-C++11 life. Move was also       traditionally there with pointer to non-const, with the sole pre-C++11       smart pointer and with various things made by developers. It was       already used so it was made better supported by language. Now there       are additionally rvalue references and two new smart pointers.              > That didn't sit well with me, because:       > 1. It doesn't take advantage of modern C++11 features, like move       > semantics.       > 2. Introduces inconsistency.              Do you presume that "set spouse" (that sets relation with other       "person" object) and "set marital status" (that only sets some enum       attribute to /married/ or /single/) can somehow be handled uniformly?              I feel that the suggested idiom can make parameter passing even       more complicated than it already is.                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca