erik quanstrom wrote:
i've found const pretty useful, dispite the fact it does create some 
inconsistencies.
it's chief virtue is that you can tell without looking any further than the 
prototype
that a function that takes a const char* makes it's own copy, if it needs one.
if you're careful with const, i think it can be a help in preventing some silly 
mistakes
that will cause a benign looking program to get up and fandango on core.
Helps various unixes with (micro?)optimizations as well, which places const data in
read only sections which then are normally shared between multiple
instances.

unfortunately, glibc, for example, is not very consistant. dispite the fact 
that it returns
a pointer into envp, glibc getenv is declared as "char* getenv(const char*);".

That's exactly how ISO C(99) and posix[1] declares it, I suppose  you
could blame them. (envp is modifiable on my BSD atleast though. C99
marks it as undefined behavior if you modify it)


[1] http://www.opengroup.org/onlinepubs/009695399/functions/getenv.html

Reply via email to