Hmm - about manifest/enum

Bruce Adams tortoise_74 at yeah.who.co.uk
Sat Dec 29 05:10:41 PST 2007


On Sat, 29 Dec 2007 03:46:19 -0000, Mike <vertex at gmx.at> wrote:

> Seems like we're running in circles again.
>
> So I simply have to ask this:
>
> Wouldn't it be better to ditch the _whole concept_ of constness and come  
> up with some thing else that actually solves problems instead of being  
> an endless stream of new problems, arguments and confusion? After all  
> this time it seems quite obvious that the problem here is constness  
> itself, not the implementation. Didn't C++ fail to get it right? So  
> maybe that's proof that the whole concept is flawed and that D won't get  
> it right either.
>
> What problem does constness solve anyway? Manifest const, read-only  
> access, const values/references ... aren't this unrelated concepts that  
> are shoehorned into one single syntax that doesn't fit?
>
> Maybe it's time for some other approach - borrow C#'s property syntax,  
> let properties stand free and make them "private scope". Borrow Pascal's  
> ":=" operator - this will mean "I define a manifest constant". Ok,  
> please don't take that too seriously, but the more discussion about  
> const we have the less faith I have that const will work in D.
>
> -Mike
>

Manifest constants has little to do with constness in the C++ sense.
It just so happens that in C++ const means both "declare a constant" and
"this is a ready only view of an object".
The issue with manifest constants is that they should not use any storage
space if they are not used. Although this sounds like just an optimisation,
the huge numbers of constants defined in the Windows headers significantly
bloat executables.
The only time C++ style constness comes back into the manifest constant  
debate
is when we start talking about the type of a manifest constant. Bizzarely
some claim we need manifest constants to declare mutable types though the  
constant
values cannot themselves be mutable by definition. Personally I think this  
is
silly.



More information about the Digitalmars-d mailing list