Generic const - a non-functional view

Walter Bright newshound1 at digitalmars.com
Tue Jun 24 13:23:10 PDT 2008


This is a hard problem. But if there's anything that I've learned from 
this whole const thing, it's that const is a hard concept for people to 
get. In order for a const system to be usable, it has to be very simple.

With functional languages, everything is const, so it is trivially 
understandable. Perl has invariant strings, but they are implicitly 
invariant and so nobody notices it, they just work.

C++ manages to hide the complexity, at the cost of const being ineffective.

D has a minimal system that is effective - const and invariant. The fact 
that it still seems to cause such misunderstanding is enough evidence 
for me to be very, very wary of adding more complexity to it.



More information about the Digitalmars-d mailing list