|
> ... a frequent source of programming errors?
It's a legitimate question, but not the one I had chiefly in mind.
A naked pointer is an expensive construct, cognitively,
because in general you don't know which of its properties are
salient to the immediate use. Can it be null? Does arithmetic
on it mean anything? Can its referent expire? Can/must I delete
it? OpCtx is so deeply threaded through the system, we soon
pick up the answers by example, but a newcomer has many other
questions to worry about.
That said, how many use-after-free errors do we have with opCtx?
We have no way of knowing, but we know that it is a common
cause of intermittent failures in similar systems.
The design load might be more important. If it turned out to be
useful to carry state along with each instance, the idea probably
would not reach the conscious level because it is not practical to
do. Given an opaque struct, it would be easy to add a member
alongside the pointer.
|