Spec#, nullables and more

retard re at tard.com.invalid
Sat Nov 6 04:49:00 PDT 2010


Sat, 06 Nov 2010 02:48:02 -0600, Rainer Deyke wrote:

> 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.

Scala doesn't have non-nullable references, but the shallow immutability 
(val) of variables makes many sloppy initialization sequences impossible. 
Usually the code ends up being of much higher quality when using vals as 
much as possible.


More information about the Digitalmars-d mailing list