null and type safety

Walter Bright newshound1 at digitalmars.com
Wed Nov 5 00:25:17 PST 2008


Robert Fraser wrote:
> Walter Bright wrote:
>> My focus is on eliminating bugs that cannot be reliably detected even 
>> at run time. This will be a big win for D.
> FWIW, I've _never_ run into a bug const could have prevented.

That isn't really the point of const. The point of const is to be able 
to write functions that can accommodate both mutable and invariant 
arguments. The point of invariantness is to be able to prove that code 
has certain properties. This is much better than relying on your 
programming team never making a mistake.

For example, you can do functional programming in C++. It's just that 
the compiler cannot know you're doing that, and so cannot take advantage 
of it. Furthermore, the compiler cannot detect when code is not 
functional, and so if someone hands you a million lines of code you have 
no freakin' way of determining if it adheres to functional principles or 
not.

This really matters when one starts doing concurrent programming.



More information about the Digitalmars-d mailing list