The motivation for const (the big picture)

guslay guslay at gmail.com
Sat Jan 5 10:04:39 PST 2008


I would appreciate if Walter or maybe someone who assisted to the D conference could enlight me.

Taking a step back from the syntax/expressiveness debate, I would like to understand better where do const/invariant reside in the grand scheme of things. Is the current const/invariant the end goal, or does it lead to something else?

Why is const/invariant necessary?

- Is it just a checklist feature? [I think it's more than that, but C++ users are accustomed to this, it might be an handicap not to have it]

- Is it mainly there because it's required to implement something else? [Say, immutable string] 

- Or is it there because it is useful just by itself? In that case, why? What's the *primary* intent?
 - To protect programmers from making mistakes?
 - For documentation?
 - As a "contract" in functions interface?
 - To enable certain optimizations?

And mainly, how does it stand with respect to pure function and functional programming? Is it required from that or is it more of a complementary feature?

Lots of questions....




More information about the Digitalmars-d mailing list