Why the need for an only const ref?
Derek Parnell
derek at psych.ward
Sat Dec 1 15:24:01 PST 2007
On Sat, 1 Dec 2007 08:33:25 +0000, Janice Caron wrote:
> 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
(a) D can't to X
(b) To try to do X in D is stupid
(c) X is a valid paradigm
therefore
(d) Wanting D to do X is stupid.
I get it now.
>> 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.
Walter, the BD of D, has been known to change his mind.
--
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell
More information about the Digitalmars-d
mailing list