3 ms·
I try to minimize use of destructors for the same reason.
by WalterBright 20d ago
I try to minimize use of destructors for the same reason.
- andrepd 20d agoDestructors run predictably at list, and are pervasive everywhere. You know that when you exit a scope, be that a function or whatever it may, the destructors of variables in that scope are called. That is clear and consistent. The transformation mentioned above is not.
- WalterBright 20d agoUnderstanding the code requires understanding the destructors of the objects you're using. Since they are invisibly inserted, they are a source difficulty in entirely understanding the code.
- rcxdude 20d agoI do wonder if any of the language servers that insert implied type annotations would ever also show things like destructor calls in a similar manner. It seems like it would be quite useful.
- otabdeveloper4 20d ago> Since they are invisibly inserted They're not, all destructors are explicit. Seems like a skill issue on your end.
- WalterBright 20d agoSince AFAIK I'm still the only person to write a correct C++ (C++98) compiler from preprocessor to object file, I know all about destructors. Here's a fun one for your amusement: foo(a, b, c); The parameters are pass by value. a, b and c are objects that have destructors. Have a look at the code generated for that. It is nice that the compiler does the dirty work for you, but the various paths with exceptions and recovery with invisible code may not be well tested.
- degaart 19d ago> Seems like a skill issue on your end. You're talking to walter bright, the guy who wrote the digital mars C++ compiler
- otabdeveloper4 18d ago> appeal to authority Okay.