Hmm - about manifest/enum

Christopher Wright dhasenan at gmail.com
Fri Dec 28 21:09:25 PST 2007


Mike 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.

It's a hard thing to define. Perhaps it's just something that's specific 
to each class, so you need to give programmers tools to define what 
const means for their code. Maybe not.

If you have a good idea for const, you're free to download the gdc 
sources and implement it....

> 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?

This is why we're using enum now for things that are compile-time 
constants. You would blanch at using enum to indicate a runtime computed 
value that you can't modify with this reference.

> 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.

I'd really love to see property syntax. And attributes, too. I would 
like an NHibernate equivalent for D, but I'd be stuck with ugly XML 
configuration, and I don't think that's a manageable solution.

> -Mike
> 



More information about the Digitalmars-d mailing list