Öö Tiib於 2018年12月3日星期一 UTC+8下午6時50分14秒寫道:
Therefore, my strategy (including from being misused) is keeping the API
simple and forcing users to check for errors explicitly (even inside the
library, I also check the underlying things for errors if convenient).
Most people don't like to check for errors explicitly rather like to see
the completed written program terse, beautiful,...,even 'smart'.
Objectively to say, we got what we want. For my part, I could work at
home writting programs quite mechanically, even mindlessly (not good,
though). 99% of bugs reported from clients are not serious and can be
identified and fixed in one day. That is the practical reason why I need
to check the API against newer c++ features in the 1st place, another
reason is pure academic, theoretical.
> > Luckily, in this illustrated case I know I can safely ignore rref things.
> > Another analogy would be like Qt's foreach. Since I don't use foreach,
> > just can imagine the labor (and the mental struggle) I would take to
> > upgrade to newer c++ version.
>
> You can always avoid making clones of library functions. There is
> std::foreach since C++98 and there is range based for since C++11.
> The chances are rather slim that your self-made version wins those.
>
My mistake, I though Qt4's foreach was invented before c++.
The analogy was trying to say that if some new c++ feature or 'keyword'
collides with or comes too close to one's existing codes, that would cause headache, e.g. thread, many people should have such experience.
> >
> > > > Hope you can see that is not an easy job. I had done such things for
> > > > pre-c++11. Even today there are still several things inconvenient to
> > > > say loudly, e.g. multiple inheritance. I appreciate your expertise
> > > > in c++. But if you examine it closely, you might end-up recall the
> > > > experience 'waste of time' again. That is what I thought and the
> > > > reason hesitate.
> > >
> > > In my programs inheritance is rare,the few inheritance trees are flat
> > > and multiple inheritance is extra rare.
> >
> > Multiple inheritance is rare is because of years of experiences and
> > evolution (something like exception specification). The bottom thing is
> > class inheritance is not that omni-capable as it used to be believed.
>
> I am programmer not politician and so I don't believe in silver bullets.
> For me inheritance is a feature of some programming languages.
> A tool like any other. That tool is meant to resolve certain
> complications with certain kind of objects. Typically the complication
> manifests itself as long methods/functions with lot of if-else or
> switch-case chains that handle that kind of objects. That can
> be fine or can make code hard to follow, test and maintain.
>
> The complication itself is infrequent and inheritance is often not the
> best tool to resolve it. A situation where same group of objects has
> several and orthogonal such complications is ultra rare. Therefore
> most usages of multiple inheritance are misuse of the tool.
>
I was talking about history. Class inheritance had been believed powerful
like crazy, so why not go further, so multiple inheritance it is.
> > > The tests are only written if
> > > these few classes with multiple inheritance behave as expected
> > > in contexts where these are used. I do not need tests how multiple
> > > inheritance works in general and in whatever context.
> >
> > 'Tests are only written..." is the problem of c++ from at least c++11
> > and latter years. Some form of program writting invented is
> > just because people focus in the beauty, efficiency or whatever fancy
> > reasons too much to underestimate the shadow side (tests not done enough).
> > At least I know 'size bloat' is not a good sign (you might find many
> > rarely used things appear in compiled files or in executibles instead).
>
> I agree that all kind of testing (unit, automated and manual) are often
> not done enough. The reason is that it is work too. Mature, well
> tested product means lot of work of highly skilled specialists. That
> is expensive. If we go extreme, 100%, no defects, then that means
> we need omnipotent specialists.
If you say it is also a work, meaning a pre-determined release is
scheduled first, than the problem is the plan, sounds to me.
No one can claim 100% correct (including this sentence).
The tests I see that could be done are quite simple, just enumerate all
usecases(unbiased) as many as possible, laborsome, though.
> It is AFAIK impossible so we have
> to balance our resource usage.
That's the trick. More invention or more tests?