Why the need for an only const ref?

Walter Bright newshound1 at digitalmars.com
Mon Dec 3 02:35:16 PST 2007


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

That's right. Const-correctness is a thing that becomes necessary when 
crossing API boundaries, it is of only minor utility for local 
references only.



More information about the Digitalmars-d mailing list