Am Tue, 15 Jul 2014 21:16:20 +0000 schrieb "bearophile" <bearophileh...@lycos.com>:
> Johannes Pfau: > > > //In runtime: > > enum int* SOME_REG = 0xFFFF; > > > > //In user code > > peek(SOME_REG); > > poke(SOME_REG); > > *SOME_REG = 1; //Oops, forgot poke! This is not acceptable > > Perhaps this syntax: > > volatile enum int* SOME_REG = 0xFFFF; > > Could turn this in a syntax error (only peek/poke are allowed to > write and read from this address): > > *SOME_REG = 1; > > Bye, > bearophile You just reinvented this DIP ;-) Once you add a volatile type qualifier, there's no need to use peek/poke. The compiler can then easily detect reads/writes to these variables and do the right thing. The DIP may seem complicated cause it considers overloading, transitivity and similar stuff. In practice almost nobody will use these features. But if I had not specified them Walters first question would have been "How does it interact with overloading" ;-)