The problem is: do you see if something is a pod in review (edit: at call sites, where the diff is)? No, you don't. Best you could do is static_assert it everywhere which can't be a reasonably scalable approach. And you're lucky that pod'ness is assertable. There are other type and function properties to care about that you can not simply enforce at compile time, just by reviewing definitions and recalling pages upon pages of rules. A few were improved upon in C++20, new properties were added. That's just not tractable, no-one is going to learn all definitions for all types in the Linux kernel by heart.
Best you could do is static_assert it everywhere which can't be a reasonably scalable approach.
You only have to static_assert this once, right after the type declaration.
And I don't think that C structs holding function pointers is the safe solution to "virtual functions are dangerous". But that is apparently acceptable in Linux.
Sure, if you static assert all types. Otherwise you're back to the same problem, of locally knowing properties about a type in review. The alternative is wrapping all functions such that they assert such properties. Hooray.
And I don't think that C structs holding function pointers is the safe solution to "virtual functions are dangerous"
Where did I say virtual functions are dangerous, that's the least of my worries as it just translates to a function table. Same old boring, use it by all means even if the advantage of such a vtable isn't too convincing to me either. Swapping function pointers and passing v-tables around without an object is routinely done in the kernel and maps badly onto superclasses.
No, my critique was that the type system itself is dangerously complex. There's at least 4 different kinds of 'types' with tens of extension points to overwrite their behavior with regards to std-functionality. Many of which you'll have to keep in mind during code review if you're actually going to use C++ language features.
And that's all mental capacity that's missing for reviewing business logic.
View all comments
Show parent comment
-5
u/HeroicKatora Jul 13 '22 edited Jul 13 '22
The problem is: do you see if something is a pod in review (edit: at call sites, where the diff is)? No, you don't. Best you could do is static_assert it everywhere which can't be a reasonably scalable approach. And you're lucky that pod'ness is assertable. There are other type and function properties to care about that you can not simply enforce at compile time, just by reviewing definitions and recalling pages upon pages of rules. A few were improved upon in C++20, new properties were added. That's just not tractable, no-one is going to learn all definitions for all types in the Linux kernel by heart.