const by default.
kris
foo at bar.com
Fri Jul 7 13:50:55 PDT 2006
BCS wrote:
> What I want is a way to get an assurance by the compiler that a
> referenced value will not be changed. This would require that const
> references (or a non mutable ones) can never be made into a mutable
> references.
Hear hear :)
Just to clarify a little on the "will not be changed" aspect: an
irresponsible user can subvert pretty much language with a cast()
facility; trapping irresponsible behaviour should *not* be considered as
part of this request. As noted before, we're not trying to cure stupidity.
Instead, we're looking for a means whereby DesignA is not /mistakenly/
subverted via pedestrian usage ~ a method in which to be more explicit
about how DesignA is intended to be used, and which the compiler can
accurately report upon.
Various pleadings to avoid incorrect usage from within the documentation
of DesignA are hardly sufficient. And CoW is missing the necessary
meta-data to understand whether a dup is required or not. Thus, there's
no way to contractually enforce CoW (ignoring various concerns regarding
CoW inefficiency and so on)
More information about the Digitalmars-d
mailing list