On Wednesday, March 07, 2012 22:36:50 Chad J wrote: > On 03/07/2012 10:08 PM, Jonathan M Davis wrote: > > On Wednesday, March 07, 2012 20:44:59 Chad J wrote: > >> On 03/07/2012 10:21 AM, Steven Schveighoffer wrote: > >>> You can use sentinels other than null. > >>> > >>> -Steve > >> > >> Example? > > > > Create an instance of the class which is immutable and represents an > > invalid value. You could check whether something is that value with the > > is operator, since there's only one of it. You could even make it a > > derived class and have all of its functions throw a particular exception > > if someone tries to call them. > > > > - Jonathan M Davis > > Makes sense. Awfully labor-intensive though. Doesn't work well on > > classes that can't be easily altered. That is, it violates this: > > - Do not modify the implementation of UnreliableResource. It's not always > > possible. > But, maybe it can be turned it into a template and made to work for > arrays too...
Personally, I'd probably just use null. But if you want a sentinel other than null, it's quite feasible. - Jonathan M Davis