Spec#, nullables and more

Rainer Deyke rainerd at eldwood.com
Sat Nov 6 01:48:02 PDT 2010


On 11/6/2010 01:12, spir wrote:
> On Fri, 05 Nov 2010 23:13:44 -0600 Rainer Deyke <rainerd at eldwood.com>
> wrote:
>> That's a faulty idiom.  A data structure that exists but contains
>> no valid data is a bug waiting to happen - no, it /is/ a bug, even
>> if it does not yet manifest as incorrect observable behavior.  (Or
>> at best, it's an unsafe optimization technique that should be
>> wrapped up in an encapsulating function.)
> 
> You may be right as for local variables. But think at elements of
> structured data. It constantly happens that one needs to define
> fields that have no meaningful value at startup, maybe even never
> will on some instances.

It doesn't happen in dynamic languages.  It doesn't happen in pure
functional languages, since these languages provide no way to alter a
data structure after it has been created.  In my experience, it happens
very rarely in C++.

If it happens "constantly" in D, then that's a flaw in the language.


-- 
Rainer Deyke - rainerd at eldwood.com


More information about the Digitalmars-d mailing list