One idea that I had about the global vs. scoped data annotations was to have them scoped by default, but if an object is created using
new at the time of definition, then an option can be set to have the object checked globally.
I’ve now realized that that’s not such a good idea. What if you want to have an object checked, but you’ve only been given that object from some library you’re using and you don’t have the source code? Or you don’t always want to have the return value of that function checked?
So I guess it has to be possible to always select global checking. But what if no value is assigned or the variable is set to
null? Then it’s going to get a whole lot more difficult to track down where that variable gets set.
The problem here stems from the fact that I’m annotating a variable, which is sort of a “static” thing (for the lack of a better word; I don’t mean Java’s
static). What I want to annotate and modify, though, is an object, a dynamic thing at runtime.
There are so many open questions now. And at first, I thought this would be easy. What if the variable gets reassigned? Does the annotation at the definition site mean that all instances assigned to the variable are checked?
Without clear semantics, predicate annotations for data become a lot less attractive… even though I still think it would be cool to call a method every time an object is accessed somehow.