Casting const/invariant

Jason House jason.james.house at gmail.com
Wed Jan 2 18:58:24 PST 2008


Daniel919 wrote:
> I recommend the use of readonly instead of const. See my post
> "const=readonly invariant=const".

Maybe using that in my post was a mistake.  I certainly don't intend to
start a syntax war.  Since I was mucking with stuff, I figured using
readonly would make stuff simpler.  Turns out that I hardly used the term
and probably could have removed it from the post.


> readonly data in general has to be treated like mutable data
> For optimization the compiler might generate two versions (of a function):
> one for the case that the data is mutable
> another for the case that the data is const

One step at a time ;)  I'd love to see an endstate with const where the
compiler knows how to handle/optimize const stuff with as little input from
the programmer as possible.



More information about the Digitalmars-d mailing list