4 ms·
Is my understanding incorrect that classes isn't an example of the first approach? "Require specifying what operations are possible in the function signature."
by operator-name 4y ago
Is my understanding incorrect that classes isn't an example of the first approach?
"Require specifying what operations are possible in the function signature." sounds a lot like classes, interfaces and inheritance to me, as a function:
void foo(Bar b);
Ensures that the operations Bar::* exist in the function signature.
- riwsky 4y agoYou’re right that classes exemplify declaring requirements upfront; the GP is limiting scope to what happens at compile time. Taking an argument of class Bar typically means taking pointers at runtime to a subclass’ method implementations. Of course, optimizing compilers (especially JITs) can often devirtualize these anyway, so it’s not even that clear-cut.