Stepping back and looking at constness from another angle.
David B. Held
dheld at codelogicconsulting.com
Wed Jun 6 20:45:18 PDT 2007
Regan Heath wrote:
> [...]
> - local variables are (until manually/explicitly assigned to another such)
> the 1st and only copy/reference of/to the data.
>
> - function parameters are implicitly a copy/alias of data. Once you have
> aliases you have complication and once you have complication you greatly
> increase the chances of unexpected changes and therefore bugs.
> [...]
Ok, Bruno probably won't like this, but he makes a great point about
orthogonality. The killer argument for orthogonality, IMO, is generics.
Remember that function argument lists are type tuples. If we say that
function arguments are const by default, that means that a given type
tuple has different meanings depending on whether it is used in a
function argument context or a non-function argument context. In fact,
it could have exactly the *opposite* meaning, which would be the worst
kind of non-orthogonality. This may seem like a faraway problem,
because I don't believe you can construct functions by assembling type
tuples and pasting them onto bits of code. But if we cement in this bit
of non-orthogonality, we guarantee that such a feature is either awkward
or impossible in the future.
Dave
More information about the Digitalmars-d
mailing list