Nullable or Optional? Or something else?

Steven Schveighoffer schveiguy at yahoo.com
Thu Sep 10 11:36:19 PDT 2009


On Thu, 10 Sep 2009 14:11:55 -0400, Rainer Deyke <rainerd at eldwood.com>  
wrote:

> Steven Schveighoffer wrote:
>> Why not?
>>
>> private Optional!double cached_x;
>> private bool cachex_valid;
>> private Optional!double cached_y;
>> private bool cachey_valid;
>
> Because that's horribly non-orthogonal code.  I go by the rule that
> whenever two pieces of data are more closely associated with each other
> members of the enclosing data structure, then those pieces of data must
> be factored out into their own data structure.  *Especially* if, as in
> this case, the resulting data structure is reusable.

Sure, do whatever you want for your *private data members*.  I see too  
much value in Optional!T being aliased to the underlying T to go for the  
completely generic solution which requires special syntax to get at the T.

-Steve



More information about the Digitalmars-d mailing list