Why the need for an only const ref?
Janice Caron
caron800 at googlemail.com
Sat Dec 1 00:33:25 PST 2007
On 12/1/07, Derek Parnell <derek at psych.ward> wrote:
> What is a D code example that catches inadverant reallocations at compile
> time?
Just don't do it. Head const is a purely local thing. The designer of
a function knows what it's supposed to do, and if they make it do
something stupid, it's a bug
> char[] Buffer = new char[MAXBUFSIZE];
> . . .
> Buffer ~= "abc"; // Oops. This is not allowed because
> // the designer wanted to avoid
> // excess memory allocations.
Const is transitive in D. Walter says that's not going to change. You
just have to deal with it.
More information about the Digitalmars-d
mailing list