Deutsch English Français Italiano |
<vanaol$3g9qu$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Thiago Adams <thiago.adams@gmail.com> Newsgroups: comp.lang.c Subject: Re: Top 10 most common hard skills listed on resumes... Date: Wed, 28 Aug 2024 11:04:05 -0300 Organization: A noiseless patient Spider Lines: 53 Message-ID: <vanaol$3g9qu$2@dont-email.me> References: <vab101$3er$1@reader1.panix.com> <vad7ns$1g27b$1@raubtier-asyl.eternal-september.org> <vad8lr$1fv5u$1@dont-email.me> <vaf7f0$k51$2@reader1.panix.com> <vafgb2$1to4v$2@dont-email.me> <vafkdk$1ut4h$2@raubtier-asyl.eternal-september.org> <20240825192810.0000672c@yahoo.com> <vafs6u$21ofd$1@raubtier-asyl.eternal-september.org> <20240825220016.00002793@yahoo.com> <86bk1e4y7t.fsf@linuxsc.com> <vajn50$2rqra$2@raubtier-asyl.eternal-september.org> <vajnha$2rtl3$1@dont-email.me> <vajns4$2rvg8$1@raubtier-asyl.eternal-september.org> <vajspc$2so1b$1@dont-email.me> <vajtdo$2ssc8$1@raubtier-asyl.eternal-september.org> <valodj$35rt8$7@dont-email.me> <vamarr$3btll$1@raubtier-asyl.eternal-september.org> <van0h7$3eqvr$1@dont-email.me> <van1sb$3f45o$1@raubtier-asyl.eternal-september.org> <van2ok$3f3q8$1@dont-email.me> <van6td$3frfe$1@raubtier-asyl.eternal-september.org> <van934$3g2ip$1@dont-email.me> <van9kt$3g7l8$1@raubtier-asyl.eternal-september.org> <vana36$3g9qu$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 28 Aug 2024 16:04:06 +0200 (CEST) Injection-Info: dont-email.me; posting-host="ff69eccb6a03ed8e39f9d9a339aa428c"; logging-data="3680094"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tPIE8zUipA+v4+eAu9QMIdGGmifPnZqs=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:AiYh2rNQyLt/IGuaFPRJNNVnQt0= In-Reply-To: <vana36$3g9qu$1@dont-email.me> Content-Language: en-US Bytes: 4651 On 28/08/2024 10:52, Thiago Adams wrote: > On 28/08/2024 10:45, Bonita Montero wrote: >> Am 28.08.2024 um 15:35 schrieb Thiago Adams: >> >>> In C you learn how to write less code. >> >> You do th same in C, but manually. >> >>> RAII, destructor, constructor is a bad idea, but I don't know if it >>> is a good place to talk about it. I also don't know if I will be able >>> to convince you. >> >> If you have a allocated resource you've to deallocate it at the end of >> the scope. In C you do that error-prone with goto-orgies like in the >> Linux-kernel. In C++ there's no goto necessary and the resulting code >> is the same. > > > You have to deallocate only if the ownership still with the same object. > This is not the case when the object is moved. > >>> One problem of RAII and destructor we cannot disable it. >> >> If you've got to deallocate the memory you need the destructor. >> If you move your container elsewhere and the compiler sees that >> the destructor is opimized away for the non-exception code-path. > > To create view object you need a new object because destructor cannot be > disabled. > > For instance > > X x; > ViewX x; //no destructor here.. > > etc.. > >>> By the way, in C++ we cannot move const objects. This is ridiculous. >> >> Const-objects are there not to be modified. If you've got logical >> constness you can cast away the const with const_cast and move its >> contents. But casting away const is unclean mostly in C and C++. > > > excuses.. > This sample (in cake) shows how I can move from const objects and how I don't need the concept of destructor and how it is safer than C++ RAII (because the fixes don't depend on programmer reading guidelines) http://thradams.com/cake/playground.html?code=I3ByYWdtYSBzYWZldHkgZW5hYmxlDQoNCiNpbmNsdWRlIDxzdGRsaWIuaD4NCiNpbmNsdWRlIDxzdHJpbmcuaD4NCg0Kc3RydWN0IFgNCnsNCiAgICBjaGFyICogX093bmVyIG5hbWU7DQp9Ow0KDQpjb25zdCBzdHJ1Y3QgWCAqIF9Pd25lciBfT3B0IG1ha2UoY29uc3QgY2hhciogbmFtZSl7DQogICAgc3RydWN0IFggKiBfT3duZXIgX09wdCBwID0gY2FsbG9jKDEsIHNpemVvZiAqcCk7DQogICAgaWYgKHApDQogICAgew0KICAgICAgIGNoYXIgKiBfT3duZXIgX09wdCB0ZW1wID0gc3RyZHVwKCJhIik7DQogICAgICAgaWYgKHRlbXAgPT0gTlVMTCkNCiAgICAgICB7DQogICAgICAgICAgZnJlZShwKTsNCiAgICAgICAgICByZXR1cm4gTlVMTDsNCiAgICAgICB9DQogICAgICAgcC0%2BbmFtZSA9IHRlbXA7DQogICAgfQ0KICAgIHJldHVybiBwOw0KfQ0KDQppbnQgbWFpbigpDQp7DQogICBfT3B0IHN0cnVjdCBYIHggPSB7fTsNCiAgIGNvbnN0IHN0cnVjdCBYICogX093bmVyIF9PcHQgcCA9IG1ha2UoIm5hbWUiKTsNCiAgIGlmIChwKXsNCiAgICAgeCA9ICpwOw0KICAgICBmcmVlKHApOw0KICAgfQ0KICAgZnJlZSh4Lm5hbWUpOw0KfQ%3D%3D&to=-1&options=