const by default.

Hasan Aljudy hasan.aljudy at gmail.com
Mon Jul 3 03:04:12 PDT 2006


Ahem.
Excuse me, I'm not very enlightened about this "const" issue, but if 
your suggestion implies that people like me who don't care about "const" 
will have to add "mutable" qualifiers all over the place, then I'm gonna 
have to side against this, with a big NO.

If I've just said something that's too stupid, then please enlighten me. 
Thanks.

Dave wrote:
> Ok, I know 'const' has been beaten to death in previous threads...
> 
> However, one thing that I've not seen beaten to death is 'const by 
> default'.
> 
> In the following post, there's a link to comp.lang.c++.moderated where 
> Walter puts forward some very good arguments regarding what's wrong with 
> C++ (type modifier) const:
> 
> http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/39437
> 
> In that thread, Walter mentions that he should have made const the 
> default. Every subsequent post agreed with not one dissenter.
> 
> Walter, what exactly do you have in mind? Only reference types? Default 
> const for everything? Everything but function local variables? Or 
> function return types and function parameters only?
> 
> If some type of 'const by default' was implemented, it could have big 
> consequences for Phobos. As Phobos is 'officially' supported and 
> distributed w/ the compiler, it is the only thing that has to be changed 
> along with the compiler.
> 
> I'd say:
> - add the 'mutable' keyword in v0.163
> - let the community start modifying Phobos.
> - add a "warn on non-mutable" switch to the compiler by v0.167 (that way 
> Walter could implement all of the logic, and later cutover by removing 
> the switch and making those errors instead of warnings).
> - let the community test Phobos using the new warning switch
> - 'cutover' when Phobos is done.
> 
> I think the "too much water under the bridge" problem from Walter's 
> standpoint is that he can't count on anyone else but himself making the 
> changes to Phobos, and he simply doesn't have the time.
> 
> I would gladly volunteer for a few of the Phobos modules but I don't 
> have the time nor enough explicit knowledge of Phobos to lead the effort 
> efficiently. If we could just get the 'mutable' keyword in there, then 
> we could start a Dsource project and get "promises" from people in the 
> community to do the work.
> 
> Just some thoughts on the matter...
> 
> Thanks,
> 
> - Dave



More information about the Digitalmars-d mailing list